Your Name il y a 3 ans
Parent
révision
007f2c3eb4

+ 37
- 0
src/pages/mine/customerAnalyse/components/LineChart.jsx Voir le fichier

@@ -0,0 +1,37 @@
1
+import React, { useEffect, useState } from 'react'
2
+import Chart from '@/components/Chart'
3
+
4
+export default (props) => {
5
+  const { dimensions, source } = props
6
+
7
+  const [options, setOptions] = useState()
8
+
9
+  useEffect(() => {
10
+    if (dimensions && source) {
11
+      setOptions({
12
+        xAxis: {
13
+          type: 'category',
14
+          axisLabel: {
15
+            rotate: 45, // 旋转 45 度
16
+          }
17
+        },
18
+        yAxis: {
19
+          type: 'value',
20
+        },
21
+        series: [{
22
+          type: 'line',
23
+          smooth: true,
24
+        }],
25
+        color: ['#5470c6'],
26
+        dataset: {
27
+          dimensions,
28
+          source,
29
+        }
30
+      });
31
+    }
32
+  }, [dimensions, source])
33
+
34
+  return (
35
+    <Chart options={options} />
36
+  )
37
+}

+ 75
- 75
src/pages/mine/customerAnalyse/index.jsx Voir le fichier

@@ -81,81 +81,81 @@ export default withLayout(() => {
81 81
     }
82 82
   }
83 83
 
84
-  const createLineOptions = (source = []) => {
85
-    const colorWithOpacity = op => `rgba(187,156,121, ${op})`
86
-
87
-    const defaultOpt = {
88
-      color: [colorWithOpacity(1)],
89
-      xAxis: {
90
-        type: 'category',
91
-        boundaryGap: false,
92
-        axisLabel: {
93
-          textStyle: {
94
-            color: '#666'
95
-          }
96
-        }
97
-
98
-      },
99
-      yAxis: {
100
-        type: 'value',
101
-        axisLabel: {
102
-          textStyle: {
103
-            color: '#666'
104
-          }
105
-        }
106
-      },
107
-      grid: {
108
-        left: '10%',
109
-        right: '8%',
110
-        bottom: '12%',
111
-        top: '15%',
112
-      },
113
-      series: [],
114
-    }
115
-    // 数据展示只展示 5 个
116
-    const endValue = source.length - 1 > 0 ? source.length - 1 : 0
117
-    const startValue = endValue - 5 > 0 ? endValue - 5 : 0
118
-
119
-    return {
120
-      ...defaultOpt,
121
-      dataset: { source },
122
-      dataZoom: [{
123
-        type: 'inside',
124
-        startValue, endValue,
125
-        show: true,
126
-      }],
127
-      series: [{
128
-        type: 'line',
129
-        dimensions: ['name', 'value'],
130
-        symbolSize: 6,
131
-        smooth: true,
132
-        label: {
133
-          show: true,
134
-          formatter: '{@value}人'
135
-        },
136
-        lineStyle: {
137
-          shadowColor: colorWithOpacity(0.5),
138
-          shadowBlur: 5,
139
-          shadowOffsetY: 7
140
-        },
141
-        areaStyle: {
142
-          color: {
143
-            type: 'linear',
144
-            x: 0,
145
-            y: 0,
146
-            x2: 0,
147
-            y2: 1,
148
-            colorStops: [{
149
-              offset: 0, color: colorWithOpacity(0.2) // 0% 处的颜色
150
-            }, {
151
-              offset: 1, color: colorWithOpacity(0) // 100% 处的颜色
152
-            }],
153
-            global: false,
154
-          }
155
-        },
156
-      }],
157
-    }
158
-  }
84
+  // const createLineOptions = (source = []) => {
85
+  //   const colorWithOpacity = op => `rgba(187,156,121, ${op})`
86
+
87
+  //   const defaultOpt = {
88
+  //     color: [colorWithOpacity(1)],
89
+  //     xAxis: {
90
+  //       type: 'category',
91
+  //       boundaryGap: false,
92
+  //       axisLabel: {
93
+  //         textStyle: {
94
+  //           color: '#666'
95
+  //         }
96
+  //       }
97
+
98
+  //     },
99
+  //     yAxis: {
100
+  //       type: 'value',
101
+  //       axisLabel: {
102
+  //         textStyle: {
103
+  //           color: '#666'
104
+  //         }
105
+  //       }
106
+  //     },
107
+  //     grid: {
108
+  //       left: '10%',
109
+  //       right: '8%',
110
+  //       bottom: '12%',
111
+  //       top: '15%',
112
+  //     },
113
+  //     series: [],
114
+  //   }
115
+  //   // 数据展示只展示 5 个
116
+  //   const endValue = source.length - 1 > 0 ? source.length - 1 : 0
117
+  //   const startValue = endValue - 5 > 0 ? endValue - 5 : 0
118
+
119
+  //   return {
120
+  //     ...defaultOpt,
121
+  //     dataset: { source },
122
+  //     dataZoom: [{
123
+  //       type: 'inside',
124
+  //       startValue, endValue,
125
+  //       show: true,
126
+  //     }],
127
+  //     series: [{
128
+  //       type: 'line',
129
+  //       dimensions: ['name', 'value'],
130
+  //       symbolSize: 6,
131
+  //       smooth: true,
132
+  //       label: {
133
+  //         show: true,
134
+  //         formatter: '{@value}人'
135
+  //       },
136
+  //       lineStyle: {
137
+  //         shadowColor: colorWithOpacity(0.5),
138
+  //         shadowBlur: 5,
139
+  //         shadowOffsetY: 7
140
+  //       },
141
+  //       areaStyle: {
142
+  //         color: {
143
+  //           type: 'linear',
144
+  //           x: 0,
145
+  //           y: 0,
146
+  //           x2: 0,
147
+  //           y2: 1,
148
+  //           colorStops: [{
149
+  //             offset: 0, color: colorWithOpacity(0.2) // 0% 处的颜色
150
+  //           }, {
151
+  //             offset: 1, color: colorWithOpacity(0) // 100% 处的颜色
152
+  //           }],
153
+  //           global: false,
154
+  //         }
155
+  //       },
156
+  //     }],
157
+  //   }
158
+  // }
159 159
 
160 160
   return (
161 161
     <view className='Page customerAnalyse flex-v'>