Chartjs-Adding a chart-js plugin to vue-chart-js

1👍

Here’s how your options object should look like:

{
  ...
  annotation: {
    annotations: [
      {<your annotation object code here>}
    ],
  },
  ...
}

Next, you’ve correctly identified that you should use the addPluing() method, just make sure to use it like so

// in imports
import SomePlugin from "..."

// in mounted
this.addPlugin(SomePlugin);

0👍

https://stackoverflow.com/a/65486537/7165219

import chartjsPluginAnnotation from "chartjs-plugin-annotation";

And:

  mounted() {
    Chart.plugins.register(chartjsPluginAnnotation);
    this.addPlugin(chartjsPluginAnnotation);
    this.renderChart(this.chartData, this.options);
  }

Leave a comment