boraerel
Posts: 4
Joined: Tue Jul 25, 2023 1:12 pm

StockChart AddSeries problem

Wed Sep 06, 2023 9:55 am

Hi,

I want to add series dynamic with this code above;


let options = {
type: 'line',
id: symbol,
name: symbol,
data: data,
yAxis: 0,
};
chart.addSeries(options);


After adding new series I make comparison type percentage like this;

chart.series.forEach((series) => {

if (compare == "value") {
min = Math.min(parseFloat(series.yData));
}
series.update({
min: min,
dataMin: min,
compare: compare
}, false);
});
chart.yAxis[0].update({ min: min,dataMin:min });

Then i remove single serie. But after i remove a serie from chart ,yAxis still starts at "0".
For example my value array min data is = 5.75 but yAxis is still at "0". how can i solve this problem?

Thanks

jedrzej.r
Posts: 534
Joined: Tue Jan 24, 2023 11:21 am

Re: StockChart AddSeries problem

Wed Sep 06, 2023 2:32 pm

Hi!

Thanks for reaching out to us with your question!

This behaviour stems from the fact that yAxis.startOnTick defaultly set to true on Highstock charts. If you set it to false, the y-axis min should stay the same, even after removing the series.

Demo: https://jsfiddle.net/BlackLabel/hw6Lneoc/

API:
https://api.highcharts.com/highstock/yAxis.startOnTick

Let me know if that was what you were looking for!
Best regards!
Jędrzej Ruta
Highcharts Developer

Return to “Highcharts Stock”