Skip to content

Show message that data is empty - Afterdraw #9165

Answered by LeeLenaleee
lironesamoun asked this question in Q&A
Discussion options

You must be logged in to vote

You need to give the plugin an id and remove the double chart for your variables

 function drawNoDataAvailable(canvaID) {
   Chart.register({
     id: 'noData',
     afterDraw: function(chart) {
       if (chart.data.datasets.length === 0) {
         // No data is present
         var ctx = chart.ctx;
         var width = chart.width;
         var height = chart.height;
         chart.clear();

         ctx.save();
         ctx.textAlign = "center";
         ctx.textBaseline = "middle";
         ctx.font = "35px normal 'Helvetica Nueue'";
         ctx.fillStyle = "gray";
         ctx.fillText(
           "No data Available",
           width / 2,
           height / 2
         );
         c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lironesamoun
Comment options

Answer selected by lironesamoun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants