chartjs / chartjs-adapter-luxon

Luxon adapter for Chart.js
MIT License
33 stars 24 forks source link

How to use in angular project? #75

Closed rhegner closed 1 year ago

rhegner commented 1 year ago

I'm using chart.js wrapped in an angular module (I'm using PrimeNG's ChartModule).

Now I'd like to use the chartjs-adapter-luxon. I added luxon and chartjs-adapter-luxon to my package.json. What else do I need to do, so that chart.js recognizes the date adapter?

I tried adding "node_modules/luxon/build/es6/luxon.js" and "node_modules/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.js" to the list of scripts in angular.json, but still no luck.

Here is a minimal example to reproduce the problem: https://stackblitz.com/edit/angular-ivy-wp9ejg?file=src/app/app.component.ts When changing the type of the x scale to 'time' on app.component.ts:23, the problem with the missing adapter can be reproduced.

rhegner commented 1 year ago

Oh... it's actually really easy.... I just added import 'chartjs-adapter-luxon'; in my app.module.ts and now it works :)