Chart.js
Simple HTML5 canvas-based charting library for creating interactive data visualizations.
3. Used by agents' projects
Dependency in 88 public GitHub projects set up for AI coding agents that we scanned (1.4%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Chart.js does
Chart.js draws charts on an HTML5 <code><canvas></code> from one <code>new Chart(ctx, config)</code> call that takes a plain config object, and since v4 registering only the components you need can shrink the bundle.
Chart.js popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Chart.js is used
- Chart.js is a dependency in 88 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.8% of the 4,867 JavaScript/TypeScript ones), #3 of 95 in charts and data visualisation.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 252; those are left out of every share on this page.
- The most used alternative in our scan is Recharts (576 projects).
- Projects that use it most often also use Tailwind CSS (80.7%), React Chart.js 2 (45.5%), Vite (55.7%).
- It is more common in projects set up for Junie (8.1%) than for GitHub Copilot (1.4%).
By coding agent
Often used with
Chart.js in practice
Strengths
The getting-started example uses a <code><canvas></code>, one CDN script tag and a single <code>new Chart(ctx, {...})</code> call. That call holds the type, labels, data and options.
Version 4 added tree-shaking. The site says registering only the components you need can reduce the bundle "by dozens of kilobytes".
The maintainers list performance work in 3.0. Their example plots 1M points with the decimation plugin enabled.
Since 2.0 you can mix bar and line charts. The site says this gives a clear visual distinction between datasets.
Watch out for
The docs say Chart.js "no longer comes with prebuilt release versions". If you download or clone the repository, you must build it to get the dist files. The docs strongly advise using another install option.
All README documentation links point to version 4. If you are on an older version, you have to put the version number in the docs URL yourself, for example <code>/docs/2.9.4/</code>.
The Chart Splat builders write that using Chart.js from PHP or other non-Node backends means running a separate Node.js service or a headless browser. They built their API because of that gap.
The script from the getting-started bar chart (needs a canvas with id myChart)
const ctx = document . getElementById ( 'myChart' ) ;
new Chart ( ctx , {
type : 'bar' ,
data : {
labels : [ 'Red' , 'Blue' , 'Yellow' , 'Green' , 'Purple' , 'Orange' ] ,
datasets : [ {
label : '# of Votes' ,
data : [ 12 , 19 , 3 , 5 , 2 , 3 ] ,
borderWidth : 1
} ]
} ,
options : {
scales : {
y : {
beginAtZero : true
}
}
}
} ) ;More about Chart.js
Head to head
- Recharts vs Chart.js used together in 25 projects
Packages around it
- tailwindcss: Utility-first CSS
- react-chartjs-2: React wrapper for Chart.js
- vite: Build tool and dev server
- typescript: Typed JavaScript
- eslint: JavaScript linter
- tailwindcss-animate: Tailwind animation utilities
More in Charts and data visualisation
Alternatives
Chart.js This page
Composable React component library for building responsive charts.
JavaScript library for creating data-driven documents with powerful data visualization capabilities.
Powerful interactive charting library for data visualization in browsers.
Interactive JavaScript charting library for creating modern data visualizations.
Get started
Install it.
npm install chart.jsRules for your agent
## Chart.js
- Install with `npm install chart.js`, or load the built files from CDNJS or jsDelivr. Do not download or clone the repository for dist files: Chart.js no longer comes with prebuilt release versions, so you would have to build it.
- Give each chart's `<canvas>` its own container element. The docs recommend this for responsiveness.
- Create charts with `new Chart(ctx, { type, data, options })`, where `ctx` is the canvas element.
- In bundled apps, consider registering only the components a chart needs. The site says this can reduce bundle size by dozens of kilobytes.
- Docs links point to v4. If a project pins an older version, read the versioned docs, e.g. `https://www.chartjs.org/docs/2.9.4/`.