html:
<div class="chart" ref="ichart"></div>
js: let chartCar = echarts.init(this.$refs.ichart) let that = this let x = this.x let y = this.y this.$axios.post('', { },{ headers: {'Content-Type': 'application/json '} }).then(res => { that.data = res.data for(let i=0;i<this.data.data.length-1;i++){ x.push(x轴) y.push(y轴) } chartCar.setOption({ title:{ text:'车流量统计折线示意图' }, tooltip: { trigger: 'axis' }, legend: { data: ['车流量统计折线示意图'], textStyle: { fontSize: 24, color: 'rgba(51,51,51,1)' } }, grid: { left:"10%", bottom:'5%', top: '15%', right: '5%' }, toolbox: { show: true, feature: { mark: {show: true}, dataView: {show: false, readOnly: false}, magicType: {show: true, type: ['line', 'bar','pic']} } }, calculable: true, xAxis: [ { type: 'category', boundaryGap: false, data: x, axisLabel: { show: true }, axisLine: { show: true } } ], yAxis: [{ type: 'value', data:[], axisLabel: { show: true }, axisLine: { show: true } }], series: [{ name: '车流量', type: 'line', stack: '总量', itemStyle: { normal: { areaStyle: { type: 'default' }, color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(40, 182, 252, 0.85)' }, { offset: 1, color: 'rgba(28, 159, 255, 0.2)' }])}}, data: y }]}) }) that.y=[] that.x=[] } }