Browse Source

【修复】能耗走势图显示大数据时的异常

程志平 4 years ago
parent
commit
db75b32e30
1 changed files with 19 additions and 5 deletions
  1. 19 5
      pages/show/show.vue

+ 19 - 5
pages/show/show.vue

@@ -8,7 +8,8 @@
 				<view class="show-item-label">能耗走势图</view>
 			</view>
 			<view class="charts-box">
-				<qiun-data-charts type="demotype" :chartData="chartData" tooltipFormat="tooltipDemo1" />
+				<qiun-data-charts type="demotype" :chartData="chartData" :opts="chartOpts"
+					tooltipFormat="tooltipDemo1" />
 			</view>
 			<view class="select-show">
 				<button class="first-button">月</button>
@@ -51,7 +52,15 @@
 					categories: [],
 					series: [{
 						data: [],
-					}],
+
+					}]
+				},
+				chartOpts: {
+					yAxis: {
+						data: [{
+							max: 0
+						}]
+					}
 				},
 				date: this.$getDate({
 					format: true
@@ -89,7 +98,7 @@
 							title: '学号或宿舍号为空,请授权',
 							duration: 3000
 						})
-						
+
 						return
 					}
 				}
@@ -183,15 +192,20 @@
 							data: [],
 						}],
 					}
+					let elc_max = 0.0
 					for (var i = 0; i < res.data.date_time.length; i++) {
 						chrt_data.categories.push(res.data.date_time[i])
 						chrt_data.series[0].data.push(res.data.use_elc[i])
+						if (parseFloat(res.data.use_elc[i]) > parseFloat(elc_max)) {
+							elc_max = res.data.use_elc[i]
+						}
 					}
-
+					let m = parseFloat(Math.abs(elc_max))
 					// console.log(chrt_data);
 					setTimeout(() => {
+						this.chartOpts.yAxis.data[0].max = parseInt(m + (m / 4.0))
 						this.chartData = chrt_data;
-					}, 1000)
+					}, 1000);
 				} else {
 					uni.showToast({
 						title: '宿舍号为空',