ng2-charts icon indicating copy to clipboard operation
ng2-charts copied to clipboard

chartjs-plugin-annotation

Open idanzror100 opened this issue 3 years ago • 4 comments

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.

idanzror100 avatar Dec 20 '21 13:12 idanzror100

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);
}

KingZofQueenZ avatar Dec 22 '21 09:12 KingZofQueenZ

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.

santam85 avatar Dec 22 '21 16:12 santam85

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:

danielalmeidagoncalves avatar Jan 19 '22 18:01 danielalmeidagoncalves

Same here, @KingZofQueenZ 's solution did the job for me: Register the plugin in the constructor instead of using [plugins]. Thank you!

herrhamilton avatar Mar 17 '22 07:03 herrhamilton

import {default as Annotation} from 'chartjs-plugin-annotation'; This works too.

AndeYashwanth avatar Oct 27 '22 13:10 AndeYashwanth

Registration done through the plugins property should also work now since the 4.0.2 version

santam85 avatar Dec 02 '22 14:12 santam85