Urgent, you can't hang up the data obtained by axios when using echarts in vue.

A line chart can be displayed when dataY is attached, but not tems, where tems and dataY data formats are the same.
< template >

<div>
   <Mheader></Mheader>
    <div id="echarts" :style="{height:height,width:width}"></div>
</div>

< / template >

< script >

import Mheader from "../base/Mheader.vue"
import echarts from "echarts"
import {getHum,getTem,getAlldata,getIllsum} from "../api"
export default {
    data() {
        return {tems:[],hums:[],illsums:[],  dataY:["5","10", "15", "30", "14"]}
    },
    props: {
        height: {
            type: String,
            "default": "300px"
        },
        width: {
            type: String,
            "default": "100%"
        }
    },
        mounted() {
            this.draw();
        },
    created(){
        this.getTems();
        this.getHums();
        this.getIllsums();

    },
    methods: {
        async getTems(){
        let tems=await getTem();
        this.tems=tems;
        console.log(tems);
    },
        async getHums(){
            let hums=await getHum();
            this.hums=hums;
        }
        ,async getIllsums(){
            let illsums=await getIllsum();
            this.illsums=illsums;
        },
        draw: function(){
            let echart = echarts.init(document.getElementById("echarts"));
            var option = ({
                title: { text: "" },
                tooltip: {},
                xAxis: {
                    data:["5","4","3","2",""]
                },
                yAxis: {},
                series: [{
                    name: "",
                    type: "line",
                    color:["red"],
                    data:[]
                }]
            });
            for(var i = 0; i < 5;iPP){

/ / option.series [0] .data [I] = this.tems [I]; cannot

                option.series[0].data[i]=this.dataY[i];
            }
            echart.setOption(option);
        }
    },
    computed: {

    },
    components: {
        Mheader
    }
}

< / script >
< style scoped lang= "less" >

-sharpecharts{
    margin: 0 auto;
    margin-top: 40px;}

< / style >

Mar.06,2021

get the data first, and then go to set and enter series data. If you write like this now, you may be able to display echart before you get the data.

if you want to take care of the data, get it first.


the problem is what the above elder brother said, this can be regarded as a small hole in echarts. Solution. First initialize the icon structure of echarts without giving the corresponding data, and then assign asynchronous data to data.
drawLinetem () {

        // domecharts
        let myChart = this.$echarts.init(document.getElementById('echartstem'))
        // 
        myChart.setOption({
            title: {text: ''},
            tooltip: {},
            xAxis: {
                data: []
            },
            yAxis: {},
            series: [{
                name: '',
                type: 'line',
                data: []
            }]
        });
        // 
        myChart.showLoading();
        $.get('http://127.0.0.1:4000/tem',function (data) {
            myChart.hideLoading();
            // 
            myChart.setOption({
                xAxis: {
                    data: ["5", "4", "3", "2", "",]
                },
                series: [{
                    // 
                    name: '',
                    data:data
                }]
            });
        }, 'json');
    }

although I haven't read the code carefully, after reading the title, I guess it's the problem of asynchronism

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