Albert
Albert

Reputation: 2115

Highstock add points to dynamically added series

I'm trying to create a highstock chart which:

  1. Renders an initial chart with one series
  2. After an event (button click) adds another series
  3. Dynamically get's updated by adding points (to both series).

1 and 2 work, but adding points to the newly (dynamically) added series doesn't seem to work, see: http://jsfiddle.net/albertsikkema/KGTBB/1/

When I add the series at chart creation time adding points work, so I'm guessing it has something to do with how the series is added.

Upvotes: 1

Views: 2754

Answers (1)

StuR
StuR

Reputation: 12238

The problem is that your navigator is an object within chart.series.

If you console log chart.series you will see that:

  • 0 = Plot line A
  • 1 = The navigator
  • 2 = Plot line B

So you are trying to addPoints onto the navigator series, instead do:

   chart.series[0].addPoint([x, y], true, true);                
   chart.series[2].addPoint([x, y], true, true); 

or, a better method would be to target your series by their name.

Upvotes: 4

Related Questions