简体   繁体   中英

Add series to highcharts dynamically without initial data

I'm trying to add & remove data series to and from Highcharts that consume dynamic data. However, my dynamically added data never renders onto the chart, even though the series has been added.

I have:

  • added the series
  • added points to the series
  • added misc series settings (name, id, desc, zindex, etc) in hopes to coerce it
  • tried redraw calls

For example:

See http://jsfiddle.net/dLovcw7x/2/

You will note that MY_NEW_SERIES never seems to render anything interesting, except a place in the legend.

Here's the consolidated version.

...
events: {
  load: function () {
      var MY_NEW_SERIES = this.addSeries({ ...config })
      var existingSeries = this.series[0] // <== i dont want this at all
      setInterval(function () {
        // as shown in HC demos...
        var x = new Date().getTime()
        var y = Math.random()
        MY_NEW_SERIES.addPoint([x, y + 0.5], true, true) // **doesn't render!**
        existingSeries.addPoint([x, y], true, true) // renders OK
      }, 1000);
  }
}

I know there are about 1M other SO posts that make this look like a dupe, but none of them are specific to dynamically adding series w/out initial data wherein addSeries has already been called and data points added.

Thx!

@Grzegorz Blachliński's comment was right on. Thx! See his comment above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM