vue3图表-js显示以前的悬停数据.
我用API数据更新了我的图表数据,但是在更新聊天数据之后,图表在悬停时显示了以前的API数据,我也尝试使用distory()。
这是我的密码
methods: {
barChart() {
var Chart = require("chart.js");
let options = new Chart(document.getElementById("bar-chart-grouped"), {
type: "bar",
data: {
labels: this.llabels,
datasets: [
{
label: "पुरुष जनसंख्या",
backgroundColor: "rgba(0, 143, 251, 0.8)",
data: this.mdata,
},
{
label: "महिला जनसंख्या",
backgroundColor: "rgba(0, 227, 150, 0.8)",
data: this.Fdata,
},
{
label: "पअन्य जनसंख्या",
backgroundColor: "rgb(254, 176, 25,0.8)",
data: this.Odata,
},
],
},
});
if (!this.chart) {
this.chart = options;
} else {
this.chart.options = options;
this.chart.update();
}
},
}发布于 2020-12-10 19:37:18
不要使用this.chart.options = options;,而是使用this.chart.options = options.options;
变量选项保存着图表,而不仅仅是选项。
更好的方法是只在该方法的第一次运行时创建图表(=>将new Chart放置在if中)
https://stackoverflow.com/questions/65092073
复制相似问题