highcharts / highcharts-vue

Other
686 stars 150 forks source link

How define setOptions global? #23

Closed kelvym closed 6 years ago

kelvym commented 6 years ago
import Vue from 'vue'
import HighchartsVue from 'highcharts-vue'

Vue.use(HighchartsVue)

Highcharts.setOptions({
    lang: {
        months: [
            'Janvier', 'Février', 'Mars', 'Avril',
            'Mai', 'Juin', 'Juillet', 'Août',
            'Septembre', 'Octobre', 'Novembre', 'Décembre'
        ],
        weekdays: [
            'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
            'Jeudi', 'Vendredi', 'Samedi'
        ]
    }
})

How use setOptions to all component

Denyllon commented 6 years ago

Thank you for contacting us.

Issues tab on this GitHub repository is our bug tracker, so next time please ask your questions by any of support channels (Highcharts Forum, StackOverflow, Email: support@highcharts.com).

To set some options to all of your charts, just use your code in the main file of your app. Here is the example showing how it should be done: https://codesandbox.io/s/43jo9klmk0

Kind Regards!

Blackcell commented 5 years ago

This is not working for me. My project implements vue-i18n as well. I need to be able to change the options on local change. I've tried to use: Highcharts.setOptions({ lang: { decimalPoint: '.', thousandsSep: ',' } }); On vue component mounted. This is not working. We also use tooltip formatter. I'm trying to wrap my head around how to integrate these moving pieces and starting with setting highchart options.

I'm wondering if the tooltip formatter is interfering with the lang options: tooltip: { shared: true, pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y:.3f}</b><br/>' },

Denyllon commented 5 years ago

Hi @Blackcell ,

Could you tell me what is not working exactly? I'm asking, because I've checked setting mentioned options on user request (button), and looks like it is working properly. Here is the demo: https://codesandbox.io/s/highcharts-vue-demo-hp4nk

Kind regards!