Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use chartjs-plugin-datalabels with vue-chartjs #10

Closed
HenriSup opened this issue Oct 26, 2017 · 7 comments
Closed

Use chartjs-plugin-datalabels with vue-chartjs #10

HenriSup opened this issue Oct 26, 2017 · 7 comments

Comments

@HenriSup
Copy link

Hi, i am actually trying to add this plugin to a vue.js project using vue-chartjs and i have no idea how to do it. I installed chartjs-plugin-datalabels using node but then what should i do?

@simonbrunel
Copy link
Member

I'm not familiar with Vue.js or vue-chartjs, did that thread help?

You will probably need vue-chartjs 2.8.7 (since this plugin requires Chart.js 2.7) and thus Vue.js 2.4.4. Then I'm not sure what is the best way to import JavaScript libraries in Vue.js, maybe simply load it via a <script> tag (so no need of the node.js package) (example):

<!-- index.html -->
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.1.0"></script>

It may be better to ask this question on the vue-chartjs project and link to that ticket.

@simonbrunel
Copy link
Member

@HenriSup did you progress on that integration?

@HenriSup
Copy link
Author

Yes sorry for the silence it was actually pretty simple just installed it via npm and imported it the way you import component in vue.js and it was on all my charts, just had to add some parameters via the data.plugin.etc.... but I'm not at work this week I'm only telling this by memory. Should I close the topic or would it be better if I add more precision and a clear way to explain how I did when I'll be back at my workplace?

@simonbrunel
Copy link
Member

Sounds great! It's a good idea to document more precisely the way you get it working, that could help other Vue.js users who want to use this plugin.

@HenriSup
Copy link
Author

HenriSup commented Nov 7, 2017

Ok, sorry for the wait i finally managed to get some time to explain how i did it (it's actually pretty simple)
-Install chartJsPluginDataLabels via npm:

npm install chartjs-plugin-datalabels --save

-import it as a component in your vue:

import ChartJsPluginDataLabels from 'chartjs-plugin-datalabels';

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  },
  components: {
    ChartJsPluginDataLabels,
  },
})

and there it is, you should have datalabels on your vue-chartjs :)
if you want to change any options on your charts it's just like the regular chartjs : https://chartjs-plugin-datalabels.netlify.com/options.html

@simonbrunel
Copy link
Member

Thanks @HenriSup for the follow up!

@folmert
Copy link

folmert commented Jul 9, 2020

I've added it to components property of my single file component, but it got applied to all my components, how can I define a scope for this?
Edit: I've solved it #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants