Update beforeDraw as inline plugin

This commit is contained in:
billz 2020-02-02 13:40:41 +00:00
parent 29772f8144
commit 9dc2a67d70
1 changed files with 63 additions and 65 deletions

View File

@ -48,19 +48,18 @@ let config = {
centerText: { centerText: {
display: true, display: true,
text: linkQ + "%" text: linkQ + "%"
},
plugins: [{
beforeDraw: function(chart) {
if (chart.config.centerText.display !== null &&
typeof chart.config.centerText.display !== 'undefined' &&
chart.config.centerText.display) {
drawLinkQ(chart);
} }
}
}]
}; };
//Chart.Chart.pluginService.register({
// beforeDraw: function(chart) {
// if (chart.config.centerText.display !== null &&
// typeof chart.config.centerText.display !== 'undefined' &&
// chart.config.centerText.display) {
// drawLinkQ(chart);
// }
// }
//});
function drawLinkQ(chart) { function drawLinkQ(chart) {
let width = chart.chart.width; let width = chart.chart.width;
@ -82,7 +81,6 @@ function drawLinkQ(chart) {
window.onload = function() { window.onload = function() {
let ctx = document.getElementById("divChartLinkQ").getContext("2d"); let ctx = document.getElementById("divChartLinkQ").getContext("2d");
window.myDoughnut = new Chart(ctx, config); var chart = new Chart(ctx, config);
//drawLinkQ(Chart);
}; };