Not sure why I had to register CategoryScale etc. #12193
-
|
I am creating a chart like this I was then invoking I am not clear on what I did to require that. AFAIK, it's not generally required (it's not in the Getting Started section of the docs, anyway). Does anyone see what I might have left out? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
This is by design in Chart.js v3+. The library moved to a tree-shakable architecture, which means components are no longer auto-registered globally. In v2, everything was bundled and registered automatically. In v3/v4, you have two options: Option 1: Register only what you need (your current approach) import { Chart, CategoryScale, LinearScale, LineController, PointElement, LineElement } from "chart.js";
Chart.register(CategoryScale, LinearScale, LineController, PointElement, LineElement);Option 2: Register everything at once import Chart from "chart.js/auto";The The Getting Started docs do mention this, but it is easy to miss. Look for the section on "Integration" — it explains the difference between the two import styles. So nothing is wrong with your setup. You just need to explicitly register the components your chart uses when importing from |
Beta Was this translation helpful? Give feedback.
This is by design in Chart.js v3+. The library moved to a tree-shakable architecture, which means components are no longer auto-registered globally.
In v2, everything was bundled and registered automatically. In v3/v4, you have two options:
Option 1: Register only what you need (your current approach)
Option 2: Register everything at once
The
chart.js/autoimport registers all controllers, scales, and elements for you — which is essentially the v2 behavior. It is si…