echarts 折线图组件 动态数据

组件代码



 

父组件代码

 

引入

import leftPart from './leftPart'
import lineChart from './lineChart'
import global from '../../Global'
import bus from '../../assets/common/js/bus'
import lineChart2 from './lineChart2'
import timeUtils from '../../assets/common/js/timeUtils'
export default {
    name: "secondTab",
    components: {
        leftPart,
        lineChart,
        lineChart2,
    },
    data(){
        return{
            myChart1:'myChart1',
            chartHeight:'200px',
            chartWidth:'1400px',
            chartFlag:false,
            chartData1: {
                xAxis: {
                    data: []
                },
                legend: {
                    data: []
                },
                series: [
                    {
                        name: '123',
                        type: 'line',
                        data: []
                    }
                ]
            },
    },
methods:{
    //获取趋势图数据
    getFirstChartData(){
        console.log(1);
        this.$axios({
            url:url,
            methods:'get',
            params:{},
        }).then((res)=>{
            if(res.status==200){
                this.chartData1.xAxis.data = 'x轴值';
                this.chartData1.series[0].name = '趋势图';
                this.chartData1.series[0].data = ‘y轴值’;
             
            }else {
                this.tips('网络故障','error')
            }
        })
    },

 

 

你可能感兴趣的:(vue,vue)