The problem of displaying legend of echarts in vue

clipboard.png
how can this kind of graph be dynamically assigned through ajax?

Mar.23,2021

you can write option in computed, and variables in option can be written in method or watch. If you change the variables, eCharts will render again

.

the following is a piece of my own code:

option: in computed

computed: {
  option () {
    return {
      legend: {
        show: true,
        bottom: 'bottom',
        data: this.typeStr
      },
      grid: {   // 
        left: '4%',
        right: '4%',
        containLabel: true
      },
      tooltip: {
        trigger: 'axis'
      },
      xAxis: {
        data: this.localDateStrAxis,
        type: 'category',
        min: 'datamin',
        boundaryGap: true,    // x
        axisLine: {
          lineStyle: {
            color: '-sharpf0f0f0'
          }
        },
        axisTick: {
          lineStyle: {
            color: '-sharpf0f0f0'
          }
        },
        axisLabel: {
          color: '-sharp5b5d61'
        }
      },
      yAxis: this.yAxis,
      series: this.series
    }
  }
}

contents of watch:

watch: {
  // eCharts
  localValueAxis: {
    handler: function (n, o) {
      this.series = []
      this.yAxis = []
      for (let i = 0; i < n.length; iPP) {
        this.series.push({
          name: this.typeStr[i],
          type: 'line',
          data: n[i],
          yAxisIndex: i,
          areaStyle: { opacity: 0.3 }
        })
        this.yAxis.push({
          name: this.typeStr[i],
          type: 'value',
          axisLine: {
            show: false
          },
          axisLabel: {
            color: '-sharp787a7d'
          },
          axisTick: {
            show: false
          },
          splitNumber: 3,
          splitLine: {
            show: true
          }
        })
      }
    },
    deep: true
  }
}

Don't worry too much about the specific code in watch. The logic is: when the value of localValueAxis changes, I ask eCharts's yAxis, series, and so on to re-assign values, and vue will naturally re-render eCharts. I hope it can help the subject.


ajax dynamic assignment echarts (pie chart and bar chart)


I want to know how the shipment volume in the middle of the ring chart is set up on the landlord's chart. I still don't know how to do it after seeing api.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e969f3-15ee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e969f3-15ee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?