5

I've installed this with npm : https://github.com/hchstera/vue-charts

Doing npm install hchs-vue-charts

Which is a package to make charts in my views.

Here is my project and I want to use ChartJS on the Dashboard.vue component

I just want to know how to import this lib from node_modules in a single component in Vuejs with the Vue-cli app (https://github.com/vuejs/vue-cli) because in their examples they do it with an instance of Vue.

Thank you

2 Answers 2

5

you must install module in main.js

import Vue from 'vue'
import VueCharts from 'hchs-vue-charts'

Vue.use(VueCharts)

then use component everywhere in you app, like this:

<template>
  <div id="app">
    <chartjs-line></chartjs-line>
  </div>
</template>

other components in lib:

<chartjs-bar/>
<chartjs-horizontal-bar/>
<chartjs-radar/>
<chartjs-polar-area/>
<chartjs-pie/>
<chartjs-doughnut/>
Sign up to request clarification or add additional context in comments.

2 Comments

There is likely some other config. Vue does not find all libs like this.
These components provided by VueCharts and registered globally. See github.com/hchstera/vue-charts/blob/…
2

In main.js import vue-charts and init the plugin like this:

import VueCharts from 'hchs-vue-charts'

Vue.use(VueCharts)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.