原地址:
echarts圖表地址
原圖:
效果圖:
問題:當數據更新時,頭部標籤不會更新。
代碼:
var myChart1 = echarts.init(document.getElementById("echartContainer1"));
console.log(this.source_data1)
myChart1.setOption({
tooltip: {},
legend: {},
toolbox: {
feature: {
saveAsImage: {}
}
},
dataset: {
source: this.source_data1
},
xAxis: {
type: 'category',
name: "時間",
},
yAxis: {
type: 'value',
name: "能耗/kWh",
min: 0,
axisLabel: {
formatter: "{value}"
}
},
series: this.xAxis_data1
});
解決方案:
myChart1.clear();
解決後代碼:
var myChart1 = echarts.init(document.getElementById("echartContainer1"));
console.log(this.source_data1)
myChart1.clear();
myChart1.setOption({
tooltip: {},
legend: {},
toolbox: {
feature: {
saveAsImage: {}
}
},
dataset: {
source: this.source_data1
},
xAxis: {
type: 'category',
name: "時間",
},
yAxis: {
type: 'value',
name: "能耗/kWh",
min: 0,
axisLabel: {
formatter: "{value}"
}
},
series: this.xAxis_data1
});