apertureless / vue-chartjs

📊 Vue.js wrapper for Chart.js
https://vue-chartjs.org
MIT License
5.54k stars 834 forks source link

How to access Chart.defaults.global #234

Closed egorzekov closed 6 years ago

egorzekov commented 6 years ago

Hello Jakub.

First of all, thanks a lot for such handy package. I appreciate your work a lot!

I easily integrated it to my project, but unfortunately faced one problem (didn't find an answer in docs/created issues).

I want to set up global settings that can change all of the fonts on the chart (http://www.chartjs.org/docs/latest/general/fonts.html).

I tried to do it with Chart.js object (http://vue-chartjs.org/#/home?id=chart-js-object), but didn't success.

Could you please clarify if it's possible to do using your package?

Many thanks in advance.

apertureless commented 6 years ago

@egorzekov

The this.$data._chart is the current chart instance. Which is created on the first renderChart call. docs

If you want to overwrite the global settings, just import Chartjs before.

import Chart from 'chart.js'

Chart.defaults.global.defaultFontColor = 'red';
urvi2429 commented 6 years ago

So this.$chart._chart is instance of vue chart.js ?

apertureless commented 6 years ago

@urvi2429 No. Like I said and mentioned in the docs http://vue-chartjs.org/#/home?id=chart-js-object

You can access the chart instance over this.$data._chart.

CamilaNiebles commented 6 years ago

@apertureless Hi! I'm trying something and I want to know if it is possible. I want to change my doughnut chart when the user make a click over it i.e, I want to show the detail about some region, is it possible? Congratulations for your work! (: