Menu

Change name of series after it has been rendered

2013-06-29
2013-10-10
  • Matthias Nick

    Matthias Nick - 2013-06-29

    Hi,

    I have chart with serveral series. Now I have an async callback, which shall now change the name of the series.

    I do:

    chart.getSeries()[0].setName("new name");

    However, the name in the chart does not change. Is there a way to change the name?

    Thanks

     
  • Shawn Quinn

    Shawn Quinn - 2013-07-05

    Unfortunately, the core Highcharts JS library does not currently support an API method to change the name of a series dynamically after it has been rendered. So, currently (at least AFAIK), the only way to do this would either be by removing the series and then re-adding a new series with the update name or via native DOM manipulation. You could also consider reaching out to the Highsoft team directly to see if they have any other options they'd recommend.

    http://api.highcharts.com/highcharts#Series
    http://www.highcharts.com/support

     
  • Michael Evans

    Michael Evans - 2013-10-03

    From: http://stackoverflow.com/questions/12419758/changing-series-color-in-highcharts-dynamically

    There does seem to be a way via update function:

    chart.series[0].update(chart.series[0].options);

    PLEASE could you add this as well as the ability to edit chart.counters.color ?

    Thanks very much.

    • I implemented the following JSNI function and it works but only for small series (pts < 100) - any idea why?

    private static native void nativeSeriesUpdateOptions(JavaScriptObject series, String newname) /-{
    series.update({ name: newname });
    }-
    /;

     

    Last edit: Michael Evans 2013-10-04
  • Shawn Quinn

    Shawn Quinn - 2013-10-10

    Very nice! Looks like they just added that new "Series.update()" method in the 3.0 release. That will provide a lot of new power to the API, so we'll get that into our backlog to get implemented (if anyone would be will to contribute this feature in the meantime, please let me know!)

    Regarding why the update doesn't work correctly for larger series, I'm not sure, but I noticed the following statement in their docs: "For a clean and precise handling of new options, all methods and elements from the series is removed, and it is initiated from scratch. Therefore, this method is more performance expensive than some other utility methods like setData or setVisible". So, you may want to try monkeying with a jsfiddle case to see if the problem you're seeing is an issue with the core library or not...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.