Chartjs-How to use chartjs-plugin-annotation in Angular

0👍

Worked for me after I changed the import statement to:

var ChartAnnotation=require('chartjs-plugin-annotation');

and changed scaleID from x-axis-0 to x-axis-1:

annotation: {
      annotations: [
          {
              type: 'line',
              mode: 'vertical',
              scaleID: 'x-axis-1',
              value: avgXValue,
              borderColor: 'red',
              borderWidth: 2,
          },
          {
            type: 'line',
              mode: 'horizontal',
              scaleID: 'y-axis-1',
              value: avgYValue,
              borderColor: 'red',
              borderWidth: 2,
          }
      ]
  } 

Leave a comment