[Chartjs]-Vue-chartjs can't import data from vue

4👍

I guess you are trying to import the lib like so:

import { Bar } from 'vue-chartjs'

This won’t work for you since you are using Vue2. To use the Vue wrapper with Vue2 you will need to import from 'vue-chartjs/legacy'. In here they have support for Vue V2 and then your application should compile just fine.

Correct import for you:

import { Bar } from 'vue-chartjs/legacy'

Comming from their readme

2👍

This error is usually coming from the fact that you’re using a Vue3 specific version. As explained here: "export 'default' (imported as 'Vue') was not found in 'vue'

Checking the releases page of vue-chartjs, we can see that v4.0.0 had a breaking change of migrating to Vue3: https://github.com/apertureless/vue-chartjs/releases/tag/v4.0.0

Hence why the v4 is causing such problem. Stay at v3.5.1 (22 august 2020) or below if you’re stuck with a Vue2 usage.

Leave a comment