yangfeng
2023-12-06 d372f82db7bf15ed38f8faf2e6b90080f9343c04
src/views/cockpitPage/components/BarChart.vue
@@ -54,11 +54,15 @@
      //   datay: [120, 200, 150, 180, 170, 150, 130, 180, 140],
      //   datay2: [20, 30, 50, 40, 70, 50, 30, 80, 40],
      // },
      startValue: 0,
      endValue: 5,
      chartTimer: null,
    };
  },
  watch: {
    "chartData.datay"(val) {
      this.startValue = 0;
      this.endValue = 5;
      this.pieChart("chart", this.chartData);
    },
  },
@@ -129,8 +133,8 @@
              type: "inside",
              xAxisIndex: 0,
              show: false,
              startValue: 0, // 从头开始
              endValue: 5, // 一次性展示几个
              startValue: that.startValue, // 从头开始
              endValue: that.endValue, // 一次性展示几个
            },
          ],
          legend: {
@@ -175,8 +179,8 @@
                  color: "#00FFFF",
                },
                formatter: function (value) {
                  if (value.length > 5) {
                    return `${value.slice(0, 4)}...`;
                  if (value.length > 4) {
                    return `${value.slice(0, 3)}...`;
                  }
                  return value;
                },
@@ -285,8 +289,8 @@
        this.chartTimer = setInterval(function () {
          // 每次向左滑动一个,最后一个从头开始。
          if (option.dataZoom[0].endValue == that.chartData.datay.length) {
            option.dataZoom[0].startValue = 0;
            option.dataZoom[0].endValue = 5;
            option.dataZoom[0].startValue = that.startValue;
            option.dataZoom[0].endValue = that.endValue;
          } else {
            option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1;
            option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1;