superman66 / vue-highcharts

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

addSeries() and Indicators #25

Closed SonOfCrypto closed 6 years ago

SonOfCrypto commented 6 years ago

Is there a way to use Indicators? I am able to import the scripts, but I can not use addSeries() to pass the data. The ema settings are beeing ignored.

this.$refs.stockOptions.addSeries( { id: 'aapl', name: 'AAPL Stock Price', data: data }, { type: 'ema', linkedTo: 'aapl' } );

Can I pass the argumets some other way?

Source: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/stock/indicators/ema

Thank you

SonOfCrypto commented 6 years ago

Oh man, just ignore my stupid question 🤦‍♂️ Just figured it out my self

this.$refs.stockOptions.addSeries( { id: 'aapl', name: 'AAPL Stock Price', data: data }); this.$refs.stockOptions.addSeries( { type: 'ema', linkedTo: 'aapl' } );

superman66 commented 6 years ago

cool

SonOfCrypto commented 6 years ago

Hi man, sorry to badger you again, but now I have a slightly different problem. I hope you can help me.

I want to use this custom extension https://github.com/streamlinesocial/highcharts-regression, but I need to set some custom series parameters.

Like in this demo http://jsfiddle.net/3g4ryLc9/ I need to add regressionSettings: {} to my series. Is there any way to make this work? The settings are beeing ignored, like I posted before. Or is there any other way to add sub-parameters?

cheers Jan

superman66 commented 6 years ago

I read highcharts docs about use third-plugin, and I found the usage as same as load highcharts module. So, can you show me the code?

SonOfCrypto commented 6 years ago

Thx for helping 👍

I forked your repo and updated your demo page for this test https://github.com/janwagner/vue-highcharts

when you click the "add series" button, the regression will not be added https://github.com/janwagner/vue-highcharts/blob/master/demo/App.vue#L63

but when the regression is added in the initial series state like here https://github.com/janwagner/vue-highcharts/blob/master/data/data.js#L41 than everything works great.

hope you can help me with this :)

superman66 commented 6 years ago

@janwagner I figure out why it does not works when you add series dynamic.

According highcharts-regression init function, when highchart init, it will be generate extraSeries and added it to Highcharts's Series.

So it works when you added in the initial data, because Highcharts will run Highchart-regression.init() when Highchars init.

But when you click the "add series", you only put it in series, but did not run Highchart-regression.init(), So It does not generate extraSeries.

jietu20180119-233411

Sadly, I have not found a solution yet. Do you have any idea?

SonOfCrypto commented 6 years ago

Not a clue :( Maybe there is a chance to destroy() whole chart element and init it again with new options? Do you know how to create a new element, after the destroy function?

superman66 commented 6 years ago

You can try it if Highcharts-regression can addSeries dynamic in pure Javascript or jQuery(without using vue.js).If it works, then we can solve it in vue.js.

SonOfCrypto commented 6 years ago

hi @superman66. the developer of https://github.com/streamlinesocial/highcharts-regression updated his script so that addSeries() now works. Thank you for your help!