我似乎无法使 legendCallback
工作。
我试过这样写:
options = {
legend: {
legendCallback: function (chart) {
console.log(chart);
return 'a';
}
}
}
OR
options = {
legend: {
},
legendCallback: function (chart) {
console.log(chart);
return 'a';
}
}
我也尝试在第二个中切换 legend
和 legendCallback
但仍然不起作用,也没有给出任何错误。
最佳答案
legendCallback 函数在选项上设置,由 Chart JS 运行,然后通过调用 chartInstance.generateLegend() 供您的调用代码使用,这将为您生成 HTML 以附加到页面上的元素。
var chartInstance = new Chart(ctx, {
type: 'line',
data: data,
options: {
legendCallback: function (chart) {
console.log(chart);
return 'a';
}
}
});
// This runs the legendCallback and returns the result
var legendHtml = chartInstance.generateLegend();
关于javascript - angular-chart.js legendCallback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39030568/