Chart.js is a great javascript library to quickly create beautiful SVG charts.

With Rails 5 it was quick and easy to install a Chart.js Gem into the asset pipeline to get started.

Rails 6 introduced Webpacker as the default Javascript pre-processor and bundler. This is a much tidier and simpler way to manage JS dependencies. Installing Chart.js into your application is now even easier:

Add Chart.js with your favourite package manager (i.e Yarn) in the console.

yarn add chart.js

Add a require() in your JS pack.

// app/javascript/packs/application.js
require("chart.js")

All done - you can now use the Chart() function throughout your application and manage Chart.js updates with ease without relying on a gem or manual files.