score:0
Accepted answer
by reading the documentation better a unique id must be configured for each registered plugin.
plugins must define a unique id in order to be configurable.
so i just added the id in my code
chart.register({
id: 'no_data_label',
afterdraw: (chart, args, options) => {
const data = chart.data.datasets[0].data;
if (data.length === 0) {
// no data is present
console.log(chart)
const current = chart.ctx;
const width = chart.width;
const height = chart.height
chart.clear();
current.save();
current.textalign = 'center';
current.textbaseline = 'middle';
current.font = "16px normal 'helvetica nueue'";
current.filltext('nessun dato disponibile', width / 2, height / 2);
current.fontcolor = "#828282";
current.restore();
}
}
});
Source: stackoverflow.com
Related Query
- ChartJS unable to register global plugin
- Unable to ES6 import ChartJS plugin into Aurelia
- How to properly use the chartjs datalabels plugin
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- Datalabels plugin chartjs showing '[object]' instead of value
- Unable to set Global Options in Chart.js
- unable to add background color to the canvas using jspdf and chartjs
- ChartJS / MomentJS - Unable to remove deprecation warning. Graph not showing in firefox/opera
- Can't apply options of datalabels chartjs plugin in Vue
- How to add ChartJS code in Html2Pdf to view image
- Unable to hide Legend in Chartjs with PrimeFaces7.0
- Chartjs with zoom plugin zooms too much with wheel just with single turn
- chartjs plugin datalabels does not show value on charts
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- Chartjs not working with d3 from csv source
- Zoom is very slow in ChartJS Zoom Plugin
- Chartjs Plugin Deferred throws "Uncaught TypeError: Cannot read property 'plugins' of undefined" error
- Can't Draw Horizontal Line on Graph Using ChartJS Annotation Plugin and Primevue Chart
- Grabbing the title in plugin for ChartJS
- ChartJS have xAxes labels match data source
- chartjs with the plugin chartjs-plugin-dragdata can i set fix dropdown values
- Chartjs v7.0 with plugin zoom, strange effect when use "drag" mode.
- Updating Chartjs to 2.5 with custom code
- How to install plugin for chartjs in javascript
- add a unit to label with chartjs plugin datalabels
- Unable to change the legend symbol to rounded square in chartjs in React
- Calling data from outside of Chartjs code
- VueJS + Chartjs - Chart only renders after code change
- Unable to plot JSON to chartJS
- Chartjs plugin label in Angular app moving unexpectedly at hover
More Query from same tag
- chartJSRadar downloadhandler creating empty png
- Chart.js TypeError: context is null
- Chart.JS customization - how to debug?
- Chart.js - Styling Legend
- Chart.js - Hover labels to display data for all data points on x-axis
- how to display name on multi series pie chart in chartjs
- Ng2-charts set color for one specific value in dataset
- Chartjs annotation plugin colored box colors get summed after switching back and forth
- How to bind json array data to chart.js with same canvas id?
- JSON Data Assigning to Javascript Var Value
- Angular 6: chartjs value not updating with dynamic value update
- Using Chart.js - Creating Legend for Doughnut Chart
- Is there a global setting in Chart.js for beginAtZero?
- How to add a custom event on legend click
- How to filter dropdown based on the choice of another dropdown in JS?
- Dataset._meta[0].dataset is null in ChartJS
- how to draw Line chart using chart.js and datalabels should be shown
- Chart js space above bar graph
- How to I optimise these javscript options which is used multiple times on different chart.js graphs?
- Reading converted rss to json file with chart.js not working
- Modifying values in a radar chart.js based on user input
- Chart.js with factory and webservices (Ionic)
- ChartJS large data range
- Change the color of the legend box and the color of the x grid lines in chart.js
- ChartJS: How to dynamically create data arrays
- Unable to parse color in line chart (angular-chart.js)
- multiple line charts with independent data Javascript (Chart.js or google-vizualisation)
- Add value to the labels on chartnewjs legend
- Draw chart.js as svg
- custom filter charts in chart.js