Prechádzať zdrojové kódy

小程序柱状图格式

wrh 2 rokov pred
rodič
commit
0f0c0b273e

+ 8 - 2
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/dataCenter/dataCenter.js

@@ -975,7 +975,6 @@ Page({
 				height: height,
 				devicePixelRatio: dpr
 			});
-			barChart.setOption(this.getGoodOrBadOption());
 			request({
 				url: '/goodOrbad/getGoodOrBadByYearAndArea?area=1',
 				method: 'GET'
@@ -987,6 +986,11 @@ Page({
 					temp.push(res.data.basicSatisfied);
 					temp.push(res.data.satisfied);
 					temp.push(res.data.great);
+					// 计算最大值,以及分割值
+					var maxValue = Math.max(...temp)
+					maxValue = parseInt(maxValue/10000 + 1) * 10000
+					var interval = maxValue / 4
+					barChart.setOption(this.getGoodOrBadOption(maxValue, interval));
 					this.setData({
 						evalutionNum: res.data.goodOrBad,
 						evalutionRate: (res.data.good / res.data.goodOrBad * 100).toFixed(2)
@@ -1081,11 +1085,13 @@ Page({
 		});
 	},
 	// 获取好差评图表
-	getGoodOrBadOption() {
+	getGoodOrBadOption(maxValue, interval) {
 		//请求数据 
 		let xAxis = {
 				type: 'value',
 				splitNumber: 4,
+				max: maxValue,
+				interval: interval,
 				axisLine: {
 					show: true
 				},

+ 8 - 2
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/dataCenterZWTJ/dataCenterZWTJ.js

@@ -242,7 +242,6 @@ Page({
 				height: height,
 				devicePixelRatio: dpr
 			});
-			barChart.setOption(this.getGoodOrBadOption());
 			request({
 				url: '/goodOrbad/getGoodOrBadByYearAndArea?area=1',
 				method: 'GET'
@@ -254,6 +253,11 @@ Page({
 					temp.push(res.data.basicSatisfied);
 					temp.push(res.data.satisfied);
 					temp.push(res.data.great);
+					// 计算最大值,以及分割值
+					var maxValue = Math.max(...temp)
+					maxValue = parseInt(maxValue/10000 + 1) * 10000
+					var interval = maxValue / 4
+					barChart.setOption(this.getGoodOrBadOption(maxValue, interval));
 					this.setData({
 						evalutionNum: res.data.goodOrBad,
 						evalutionRate: Math.round(res.data.good / res.data.goodOrBad * 100)
@@ -297,11 +301,13 @@ Page({
 		};
 	},
 	// 获取好差评图表
-	getGoodOrBadOption() {
+	getGoodOrBadOption(maxValue, interval) {
 		//请求数据 
 		var xAxis = {
 				type: 'value',
 				splitNumber: 4,
+				max: maxValue,
+				interval: interval,
 				axisLine: {
 					show: true
 				},