许静 5 年前
父节点
当前提交
6bd9256203
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 5
    4
      src/components/charts/Line.js
  2. 2
    3
      src/pages/person/customerAnalysis/analysis.js

+ 5
- 4
src/components/charts/Line.js 查看文件

@@ -35,9 +35,8 @@ export default class LineChart extends Component {
35 35
 
36 36
   // 禁止 props 变更时渲染
37 37
   shouldComponentUpdate(nextProps) {
38
-    console.log('------------>', this.props, nextProps)
39 38
     if (nextProps.source && nextProps.source.length) {
40
-      this.refreshChart(this.props.source)
39
+      this.refreshChart(nextProps.source)
41 40
     }
42 41
 
43 42
     return false
@@ -78,7 +77,7 @@ export default class LineChart extends Component {
78 77
         left: '10%',
79 78
         right: '8%',
80 79
         bottom: '10%',
81
-        top: '6%',
80
+        top: '10%',
82 81
       },
83 82
       series: [],
84 83
     }
@@ -126,7 +125,7 @@ export default class LineChart extends Component {
126 125
 
127 126
   refreshChart(source) {
128 127
     const options = this.createOptions(source)
129
-    console.log(source,"source")
128
+
130 129
     if (!this.echart) {
131 130
       if (this.ecComponent) {
132 131
         const initFunc = initChart(this.handleChart.bind(this), options)
@@ -140,6 +139,8 @@ export default class LineChart extends Component {
140 139
   }
141 140
 
142 141
   render() {
142
+    // this.refreshChart(this.props.source)
143
+
143 144
     return (
144 145
       <View className="map-container">
145 146
         <ec-canvas ref={this.handleEcComponent} ec={this.state.ec}></ec-canvas>

+ 2
- 3
src/pages/person/customerAnalysis/analysis.js 查看文件

@@ -77,7 +77,7 @@ export default class analysis extends Taro.Component {
77 77
       res.map((item, index) => {
78 78
         arr.push({ value: item.customerNum, name: item.day })
79 79
       })
80
-      console.log(arr, "88888888888888888888888888888888888")
80
+
81 81
       this.setState({
82 82
         chartInfo: arr || []
83 83
       })
@@ -94,15 +94,14 @@ export default class analysis extends Taro.Component {
94 94
         res.map((item, index) => {
95 95
           arr.push({ value: item.customerNum, name: item.day })
96 96
         })
97
-        console.log(arr, "88888888888888888888888888888888888")
98 97
         this.setState({
99 98
           chartInfo: arr || []
100 99
         })
101 100
       })
102 101
     } else {
103 102
       getEchartMonthInfo(params).then(res => {
104
-
105 103
         this.setState({
104
+          chartInfo: res.map(x => ({ name: `${x.month.substr(4)}月`, value: x.customerNum }))
106 105
         })
107 106
       })
108 107
     }