ng2-charts
ng2-charts copied to clipboard
chartjs-plugin-annotation
hi could you give me an example for how to add chartjs-plugin-annotation to last version of ng2-chart? because i can not get it work after uprade from this : https://stackblitz.com/edit/angular-juufpv?file=src%2Fapp%2Fapp.component.ts
thank you.
Imports:
import { Chart } from "chart.js";
import AnnotationPlugin, { AnnotationOptions, AnnotationPluginOptions } from "chartjs-plugin-annotation";
Registration must be done in Constructor. I couldn't get it to work with [plugins] annotation.
constructor() {
Chart.register(AnnotationPlugin);
}
There is an example in the pieChart (https://valor-software.com/ng2-charts/#PieChart) but indeed seems not to work completely as expected. Will have a look.
Same here as @KingZofQueenZ and @idanzror100 with Chartjs 3.4.0, ngChart 3.0.0-rc.7 and chartjs-plugin-annotation 1.2.2. It would be super nice to have focused documentation about this for example on the ngChart website because this kind plugins adds a lot of functionality to the lib and I know a few teams that are using it. By the way, thanks for the awesome integration :+1:
Same here, @KingZofQueenZ 's solution did the job for me: Register the plugin in the constructor instead of using [plugins]. Thank you!
import {default as Annotation} from 'chartjs-plugin-annotation';
This works too.
Registration done through the plugins property should also work now since the 4.0.2 version