Ver Fonte

图表加刻度值

skcj há 2 anos atrás
pai
commit
b0a2a95662
1 ficheiros alterados com 59 adições e 1 exclusões
  1. 59 1
      ruoyi-ui/src/components/xxtjEcharts/EchartsBox5/index.vue

+ 59 - 1
ruoyi-ui/src/components/xxtjEcharts/EchartsBox5/index.vue

@@ -201,7 +201,7 @@ export default {
       // 是否显示xy轴
       let yAxis = yData;
       let seriesdata = [];
-
+      let zbz=this.zbz;
       if (type === 'pie' || this.hengzhu === 'yes') {
         let array = this.radioLabel.slice(1)
         yAxis = array.map((item, index) => {
@@ -248,6 +248,52 @@ export default {
           })
         }
 
+        seriesdata.push({
+          type: "line",
+          markLine: {
+            symbol: ["none", "none"], //去掉箭头
+            itemStyle: {
+              normal: {
+                lineStyle: {
+                  type: "dashed", //线条样式
+                  color: {
+                    //设置渐变
+                    type: "linear",
+                    x: 0,
+                    y: 0,
+                    x2: 0,
+                    y2: 1,
+                    colorStops: [
+                      {
+                        offset: 0,
+                        color: "red ", // 0% 处的颜色
+                      },
+                      {
+                        offset: 1,
+                        color: "red", // 100% 处的颜色
+                      },
+                    ],
+                    global: true, // 缺省为 false
+                  },
+                },
+                label: {
+                  show: true,
+                  position: "center", // 文字显示的位置
+                },
+              },
+            },
+            data: [
+
+              {
+                name: "max line on close",
+                type: "min",
+                // valueDim: "close",
+                yAxis: zbz, // 第二条标记线x轴的值
+              },
+            ],
+          },
+        })
+
       }
 
       var myChart = this.$echarts.init(document.getElementById(id))
@@ -279,6 +325,18 @@ export default {
           type: 'value',
           scale: true,
           // inverse: true,
+          min: function(value) {//取最小值向下取整为最小刻度
+            let min=Math.ceil(value.min);
+            if (zbz<min)
+              min=zbz;
+            return  min;
+          },
+          max: function(value) {//取最大值向上取整为最大刻度
+            let max=Math.ceil(value.max);
+            if (zbz>max)
+              max=zbz;
+            return  max;
+          },
           show: true,
           name: '单位:' + unit,
           nameTextStyle: {