highcharts-vue icon indicating copy to clipboard operation
highcharts-vue copied to clipboard

Added: HighchartsVue.use for easy registration of features

Open richardeschloss opened this issue 5 years ago • 2 comments

This PR suggests a much simpler implementation for registering additional Highcharts features, such as exporting, mapChart, and stockChart.

Prior to this PR, the developer had to register the feature like this:

import Highcharts from 'highcharts'
import stockInit from 'highcharts/modules/stock'
stockInit(Highcharts)

However, this doesn't always work, since it sometimes throws an error "TypeError: Cannot read property 'parts/Globals.js' of undefined" as described here...that problem required a (typeof Highcharts === 'object') check, but there's an even simpler way for both you guys and people that use the wrapper. Simply define a "use" property (method) on the wrapper, and let that method handle everything. This results in extremely simple code that's easy to maintain (and less docs to update):

import Vue from 'vue'
import HighchartsVue from 'highcharts-vue' // So, people were already doing this... 
import { mapData } from 'js/worldmap'

// Just tell HighchartsVue what features to use:
HighchartsVue.use('exporting')
HighchartsVue.use('stockChart')
HighchartsVue.use('mapChart', { mapName: 'myMapName', mapData })

Easy!

--- 

Also: the linter required some updating just so I could get the linter to pass 


richardeschloss avatar May 12 '20 03:05 richardeschloss

hi richard, do you know how to enable stock tools or indicators ?

nicqchen avatar Nov 08 '20 12:11 nicqchen

Hi @nicqchen , I think these two links will help:

  • https://www.highcharts.com/docs/stock/technical-indicator-series --> links to a bunch of demos*. It seems like the indicators are already predefined types
  • https://www.highcharts.com/demo/stock/stock-tools-custom-gui --> shows a gui concept with some functionality (I think it's more conceptual, as I can't seem to get all the buttons to work).

richardeschloss avatar Nov 08 '20 21:11 richardeschloss