Chartjs-How to use chart.js in webpacker rails 6

1👍

ok with trial error I found a way
this is how I need to call it in application.js

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

0👍

Solution provided was ok until I began facing problems in production environment due some async loads. In my case I solved this loading Chart.js synchronously and making it global available as following:

const Chart = require('chart.js/auto');
window.Chart = Chart.Chart;

Leave a comment