循环this.dataAndScore获取到数据后,直接通过option赋值给echart

const Xdata = [];   //定义数组Xdata 
const Sdata = [];   //定义数组Sdata 
for (let i = 0; i < this.dataAndScore.length; i++) {    //遍历this.dataAndScore
    const item = this.dataAndScore[i];
    Xdata.push(item.data);          //将本次循环的日期放入Xdata
    Sdata.push(item.score);         //将本次循环的成绩放入Sdata
}

this.options = {  //echarts图表信息
   xAxis: { 
       type: 'category',
       ...
       data: Xdata   //xAxis获取动态值Xdata 
   },
   yAxis: { 
       type: 'value',
       ...
       axisLabel: ....
   },
   series: { 
       name: 'score',
       ...
       data: Sdata, //series获取动态值Sdata 
       ...
   }
   
},

Logo

前往低代码交流专区

更多推荐