DEV Community

Discussion on: ChartJS with Rails 6 and Webpacker

Collapse
 
julrocas profile image
Julio Castillo

Super useful!
I've also found that if you want to use Chart.js in your views you can register it globally in application.js like this


import Chart from 'chart.js/auto';
global.Chart = Chart;

Enter fullscreen mode Exit fullscreen mode

And then you can call new Chart(...) in your views :D

Collapse
 
wanderingsoul profile image
Jameel Ur Rahman

Thanks for the tip!

Collapse
 
johnpitchko profile image
John Pitchko

This was perfect; thank you for sharing.