Menu

Change chart color Dynamically

Naveen
2012-09-08
2012-09-19
  • Naveen

    Naveen - 2012-09-08

    Hi,
    I want to change the color of series, based on the point which is added dynamically.
    I tried setting plotoptions for that series but it dint worked out for me.
    Any help would be appreciated.

     
  • Philippe Lhoste

    Philippe Lhoste - 2012-09-11

    The PlotOptions JavaDoc says:

    Also note that changing the plot options for a series after it has been rendered to the screen does not change the way the live series will appear. If you need to change the plot options after the series is rendered, you'd instead need to first remove() the series from the chart and then re-add it to the chart via the Chart.addSeries(Series) method.

    Something like:

    chart.removeSeries(secondChartSeries, false);
    secondChartSeries.setPlotOptions(new SplinePlotOptions().setColor("#08F"));
    chart.addSeries(secondChartSeries, true, false);
    

    works for me, although the new plot option creation makes the marker style to change, and I see no way to get the current plot options to avoid this.

     
  • Naveen

    Naveen - 2012-09-13

    Yes, I have got using this. But one concern is the dynamic points which we add are getting lost.

     
  • tvhnet

    tvhnet - 2012-09-19

    You can use: series.setOption("color", "#08F");

     

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.