Mikkel Rom Engholm
Mikkel Rom Engholm

Reputation: 11

HighStock - Add series dynamically to navigator

I'm using the AddSeries method for my HighStock chart, and I would like the added series to also show up in the navigator.

In the documentation for the HighStock AddSeries method it is described that this is not possible: http://api.highcharts.com/highstock/Chart.addSeries

In a StockChart with the navigator enabled, the base series can't be added dynamically

I would like to ask if there is any workaround for this? Is this a feature that is coming soon, or is there a good reason for why the series aren't added to the navigator?

The only workaround I can think of is to destroy the entire chart and create a new one with both the old and new series. This seems kinda hacky, and I would prefer to just use the AddSeries method, since I think it makes more sense.

Thanks :)

EDIT

I found out that (with help from Grzegorz Blachliński) it works if the type is not line (which is the default). I didn't provide the type property, which was why it wasn't working. Still don't get why line makes it break though.

//Solution:
chart.addSeries({
    name: 'name',
    type: 'area',
    color: 'red',
    yAxis: 'nameOfYAxis',
    data: data,
    showInNavigator: true
});

Thanks a lot Grzegorz Blachliński :)

Upvotes: 1

Views: 1734

Answers (1)

Grzegorz Blachliński
Grzegorz Blachliński

Reputation: 5222

I think that in your case you should be able to use showInNavigator option for adding series both to your chart and to your navigator. You can find more information about showInNavigator in Highcharts API:

http://api.highcharts.com/highstock/plotOptions.series.showInNavigator

chart.addSeries({
  data: data2,
  showInNavigator: true,
});

Live example of adding series to navigator: http://jsfiddle.net/g51L5mpL/4/

Upvotes: 3

Related Questions