quanyawei
2023-09-19 076d8685573236fd044bdbcd167b60652e8799cd
src/components/Echarts/LineChart2.vue
@@ -27,6 +27,10 @@
      type: Boolean,
      default: true,
    },
    isMouse: {
      type: Boolean,
      default: false,
    },
    chartData: {
      type: Object,
      required: true,
@@ -89,6 +93,42 @@
        return res * fontSize
      }
      let that = this
      if (this.isMouse) {
        this.chart.on('mouseover', function (params) {
          that.chart.setOption({
            series: [
              {
                name: params.seriesName,
                label: {
                  show: true,
                  fontSize: 16,
                  position: [10, -15],
                  formatter: '{c}'
                }
              }
            ]
          })
        })
        // 增加监听,mouseout事件(鼠标离开)
        this.chart.on('mouseout', function (params) {
          that.chart.setOption({
            series: [
              {
                name: params.seriesName,
                lineStyle: {
                  width: 2
                },
                label: {
                  show: false
                },
                endLabel: {
                  show: false
                }
              }
            ]
          })
        })
      }
      this.chart.setOption(
        {
          title: {
@@ -188,8 +228,14 @@
          yAxis: {
            axisTick: {
              show: false, // 轴线刻度
              show: true, // 轴线刻度
            },
            axisLine: {
              show: true, //不显示坐标轴线
            },
            axisLabel: {
              show: true, //不显示坐标轴上的文字
            }
            // axisLine: {
            //   lineStyle: {
            //     color: '#000000'