superman66 / vue-highcharts

The Component of Vue 2.x for highcharts
https://codesandbox.io/s/jjyqvv0k13
MIT License
115 stars 48 forks source link

Global Highcharts methods, e.g. setOptions #26

Closed dpgalloway closed 6 years ago

dpgalloway commented 6 years ago

How can I apply global highcharts methods? For example, I'd like to set the thousands separator to comma, which in the Highcharts documentation is done by doing this (http://jsfiddle.net/highcharts/eeDnv/):

Highcharts.setOptions({
    lang: {
        decimalPoint: '.',
        thousandsSep: ','
    },
});

I've tried this.$refs.highchart.delegateMethod('setOptions')... but that gives an error (can't apply undefined). I've also tried this.$refs.highchart.chart.setOptions()... but that also gives an error that setOptions is not a function.

superman66 commented 6 years ago

this.$refs.highchart this Highchart Instance is correct?

superman66 commented 6 years ago

hey @dpgalloway, I found it works below: in Javascript, you can use like normal Highcharts usage,

Highcharts.setOptions({
  lang: {
    drillUpText: 'back',
  },
})

in HTML: you should add Highcharts as props

<vue-highcharts :Highcharts="Highcharts" :options="options" ></vue-highcharts>
dpgalloway commented 6 years ago

@superman66 Thank you for the answer, but I couldn't get that to work (error that Highcharts is undefined). I ended up just using vanilla Highcharts since my needs are fairly simple and don't need to rely on Vue. However, if you have a snippet of working code using the method you described above, others may find it useful (could also add to documentation).

superman66 commented 6 years ago

you can see this demo LoadModuleChart.vue

superman66 commented 6 years ago

@dpgalloway hi, has your problem been solved?