const setDivChartData = (data,tabType) => {
let xAxisData:any[] = [];
if(tabType === 'first') {
const mapBaseData = data.map(item => item.base);
const xAxisData = [...new Set(mapBaseData)];
const yAxisData = getYDivChartDataByBase(xAxisData,data);
console.log(yAxisData,'yAxisData');
const sortYAxisData = yAxisData.sort((a, b) => Number(b.name) - Number(a.name));
const mapNameList = sortYAxisData.map(item => item.name);
echartLayoutVal.value.byDivison.option.legend.data = mapNameList;
echartLayoutVal.value.byDivison.option.xAxis.data = xAxisData;
echartLayoutVal.value.byDivison.option.series = setDivBaseChartDefaultColor(sortYAxisData);
} else if(tabType === 'second') {
xAxisData = monthList;
}
};
vue3+echarts项目中改变echartLayoutVal.value.byDivison.option.series,为什么界面echart图没有更新
强制 Vue 检测变化
以下是完整的代码
具体改动如下