Chartjs-Can't Draw Horizontal Line on Graph Using ChartJS Annotation Plugin and Primevue Chart

0๐Ÿ‘

โœ…

We hit a similar problem and needed to make sure we globally register the annotation plugin in our project root.

Without this, the annotation silently fails just as you are describing:

import { Chart } from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
Chart.register(annotationPlugin);

Also, just referencing the annotation in your options object is enough. No need for the plugins argument to the Chart component itself here:

<Chart    
  type="line"
 :data="data"
 :options="options"
 :plugins="annotationPlugin"
/>

Source: https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/integration.html#bundlers-webpack-rollup-etc

Leave a comment