邹能昇 2 сар өмнө
parent
commit
49d0d18978

+ 24 - 23
nova-werun/pages/home/statistics/index.js

@@ -2,6 +2,7 @@
 import * as echarts from "../../../components/ec-canvas/echarts.min"
 const Parse = getApp().Parse;
 const company = getApp().globalData.company;
+
 function initChart(canvas, width, height, dpr) {
     const chart = echarts.init(canvas, null, {
         width: width,
@@ -14,17 +15,17 @@ function initChart(canvas, width, height, dpr) {
             type: 'category',
             data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
             axisLabel: {
-                formatter: function(value, index) {
+                formatter: function (value, index) {
                     const dates = ['1号', '2号', '3号', '4号', '5号', '6号', '7号'];
-                    return index === 1 ? '今天' : value + '\n'+'\n' + dates[index]; 
+                    return index === 1 ? '今天' : value + '\n' + '\n' + dates[index];
                 }
             }
-          },
-          yAxis: {
+        },
+        yAxis: {
             type: 'value',
             max: 20000, // 设置Y轴最大值为20000
             axisLabel: {
-                formatter: function(value) {
+                formatter: function (value) {
                     if (value >= 10000) {
                         return (value / 10000) + 'k'; // 格式化为20k
                     }
@@ -32,29 +33,27 @@ function initChart(canvas, width, height, dpr) {
                 }
             }
         },
-          series: [
-            {
-              data: [
+        series: [{
+            data: [
                 12000,
                 {
-                  value: 12000,
-                  itemStyle: {
-                    color: '#a90000',
-                  }
+                    value: 12000,
+                    itemStyle: {
+                        color: '#a90000',
+                    }
                 },
                 12000,
                 12000,
                 12000,
                 12000,
                 12000
-              ],
-              type: 'bar',
-              barWidth:'10',
-              itemStyle: {
-                borderRadius:15,
-            }
+            ],
+            type: 'bar',
+            barWidth: '10',
+            itemStyle: {
+                borderRadius: 15,
             }
-          ],
+        }],
     };
     chart.setOption(option);
 
@@ -92,8 +91,8 @@ Page({
             onInit: initChart
         },
 
-        percentage:'',
-        percent:'',
+        percentage: '',
+        percent: '',
 
     },
 
@@ -304,11 +303,13 @@ Page({
         if (percent > 100) {
             percent = 100;
         }
+        // 保留两位小数
+        percent = parseFloat(percent.toFixed(2));
         this.setData({
             percent,
-            percentage:`conic-gradient(from 0deg, #015EEA ${percent}%, white 0%)`,
+            percentage: `conic-gradient(from 0deg, #015EEA ${percent}%, white 0%)`,
         })
-        console.log('百分比',this.data.percentage);
+        console.log('百分比', this.data.percentage);
     }
 
 })