victorgarciaesgi / vue-chart-3

📊 A simple wrapper around Chart.js 3 for Vue 2 & 3
https://vue-chart-3.netlify.app/
MIT License
309 stars 108 forks source link

error with demo Vue 2 + composition API #109

Closed scil closed 2 years ago

scil commented 2 years ago

Describe the bug

I follow this demo Vue 2 + composition API: CodeSandbox demo Vue 2 + composition

got error like ERROR Error: "linear" is not a registered scale

scil commented 2 years ago

how to fix

same error: https://github.com/sgratzl/chartjs-chart-wordcloud/issues/4

chart.js 3 is ESM tree shakeable and requires to register all components that you are going to use. Thus, you have to register the linear scale manually

so add this line

import { Chart, registerables } from 'chart.js';Chart.register(...registerables);
scil commented 2 years ago

And plugin zoom is also needed.

 npm i chartjs-plugin-zoom
import { Chart, registerables } from 'chart.js';
import zoomPlugin from "chartjs-plugin-zoom";
Chart.register(...registerables, zoomPlugin);