-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Codebase for update plugin to chartjs 3.x
function checkIsEmpty(chart) {
if (chart.config.type == "doughnut") {
var values = chart.data.datasets[0].data;
if (values.length == 0) {
return true;
}
for (i = 0; i < values.length; i++) {
if (values[i] != 0) {
return false;
}
}
return true;
}
return chart.data.datasets[0] == null || chart.data.datasets[0].data.length === 0;
}
Chart.register({
id: 'overlay',
afterDraw: (chart, args, opts) => {
if (checkIsEmpty(chart)) {
var ctx = chart.ctx;
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = "22px Arial";
ctx.fillStyle = "gray";
ctx.fillText('Sem dados', chart.width / 2, chart.height / 2);
ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
ctx.fillRect(0, 0, chart.width, chart.height);
ctx.restore();
}
}
});
I create this source code, inspired into plugin.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels