Vue-Chart-3 is a modern, TypeScript-first wrapper for Chart.js 4, specifically designed for use with Vue 3's Composition API. It provides a suite of reactive Vue components that streamline the integration of various Chart.js chart types, such as Bar, Line, and Doughnut, into Vue applications. Currently at version 4.0.1, the package is actively maintained with a focus on seamless compatibility with Chart.js 4, Vue 3.5+, and contemporary build tools like Vite.js and Nuxt 3. Its key differentiators include comprehensive TypeScript support, leveraging the Composition API for efficient reactivity, and ensuring robust functionality within the latest Vue and Chart.js ecosystems.
npm install vue-chart-3Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up and render a reactive Bar Chart using `vue-chart-3` and Chart.js in a Vue 3 Composition API component, including global Chart.js registration and dynamic data updates.
Ensure `chart.js` is `^4.0.0` and `vue` is `>= 3`. Follow the migration guide for Chart.js v4 and Vue 3 if upgrading from older major versions.
Add `import { Chart, registerables } from 'chart.js'; Chart.register(...registerables);` at your application's entry point or in a global plugin. Alternatively, import and register specific Chart.js modules for smaller bundle sizes.Install `chart.js` with `^4.0.0` and `vue` with `>= 3` alongside `vue-chart-3`. Verify your Node.js version meets the `>=20` requirement.
Ensure you are using `vue-chart-3` version 3.1.8 or higher, or the latest 4.x release, to benefit from improved reactivity watchers.
Refactor chart components to import and use the specific `vue-chart-3` components (e.g., `<BarChart>`) directly, passing `chartData` and `options` as props.
Ensure `Chart.register(...registerables);` is called only once globally in your application's entry file (e.g., `main.ts` or a Vue plugin) before any chart components are mounted.
Import the desired chart component from `vue-chart-3` (e.g., `import { LineChart } from 'vue-chart-3';`) and declare it in your Vue component's `components` option, or use it directly in a `<script setup>` context.Import `Chart` and `registerables` from `chart.js` and call `Chart.register(...registerables);` once globally. For tree-shaking, import and register only the necessary components from `chart.js` (e.g., `CategoryScale`, `LinearScale`, `Tooltip`, `Legend`, `BarElement`).
Ensure your project's `package.json` explicitly lists `"chart.js": "^4.0.0"` and `"vue": ">= 3"` in `dependencies` and install them. Use `npm install --force` or `npm install --legacy-peer-deps` as a last resort, but first, verify compatible versions.
Always use ES module `import` syntax (e.g., `import { BarChart } from 'vue-chart-3';`) as `vue-chart-3` supports ESM builds since v3.1.0 and is a modern Vue 3 library.