Echarts is used to draw a line chart in vue, why the data is not displayed?

problem description

A novice asks for advice. Echarts is used as a line chart in Vue. The data is transmitted from the background Ajax, but the data is not displayed at all. How is this going on?

the environmental background of the problems and what methods you have tried

the data is transmitted from the background Ajax, and the background interface is written in Django. It is transmitted to the sub-components through props, and the data is also accepted in the sub-group price, but the data is invalid when it is transferred to the data of Echarts?

related codes

<template>
    <div id="chart" style="height:400px;width:100%;"></div>
</template>

<script>
export default {
  props: {
    time: {
      type: Array
    },
    stock: {
      type: Array
    }
  },
  data: function () {
    return {
      myChart: "",
      option: {
        title: {
          text: ""
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross"
          }
        },
        toolbox: {
          show: true,
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: this.time
        },
        yAxis: {
          type: "value",
          axisLabel: {
            formatter: "{value} "
          },
          axisPointer: {
            snap: true
          }
        },
        series: [
          {
            name: "",
            type: "line",
            color: "green",
            smooth: true,
            data: this.stock
          }
        ]
      }
    }
  },
  created () {
  },
  mounted () {
    this.drawLine()
  },
  methods: {
    drawLine: function () {
      this.myChart = this.$echarts.init(document.getElementById("chart"))
      this.myChart.setOption(this.option)
    }
  }
}
</script>

what result do you expect? What is the error message actually seen?

there is no error message, and the normal result is as follows:

clipboard.png
:

clipboard.png

Apr.09,2021

When

this component executes mounted () , ajax may not have the data, although it is later filled in through props, but the form is not refreshed.

you can first log the data in mouted to see if you have got the data at that time

  1. the parent component uses vMuIf = "this.time.length" on the tag of the child component, and render
  2. when the data arrives. Use watch to listen for changes in props in
  3. subcomponents, and call this.drawLine () to redraw
  4. if there are any changes.
  5. or some other similar method

has been solved. I'll just put the drawing method in the axios callback function.

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-1e81c8a-4e053.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-1e81c8a-4e053.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?