I use a chart with one series which I need to update with different points on user's action (the chart is a histogram, and the user changes the step - influencing this way the number of bins). As a start I calculate the initial points, add them to the series - with series.setPoints(Point[])) - and add series to the chart - this works OK. When the user changes the parameters, I recalculate the points, use chart.getSeries(seriesId) to retrieve the series and on the retrieved series set the recalculated points - again with series.setPoints(Point[]). This works fine - the plot updates correctly, but if I do it only once (this is strange that it works once and not again), but if I do it for the second time the plot doesn't update.
If I do the same by removing points one by one (with series.removePoint(Point)) and then add the new points one by one (with series.addPoint(Point)) everything works fine every time. However, I prefer the setPoints method as it works more efficiently.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm, that does sound odd. We use setPoints() regularly here for most of the charts in GWT applications that support dynamic updates, and haven't noticed this kind of an issue. Can you boil this does to a smaller code example/use case that you can post here so that we can take a closer look to see what may be going wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the late reply, but I haven't noticed your answer until today.
Taking the relevant part from my code, it looks like the example below:
This works:
Series histogramSeries = this.getSeries(histogramSeriesID);
for (Point p : histogramSeries.getPoints()) {
histogramSeries.removePoint(p, false, false);
}
for (Point p : points) {
histogramSeries.addPoint(p, false, false, false);
}
histogramSeries.update(histogramSeries);
This doesn't work (works only once):
Series histogramSeries = this.getSeries(histogramSeriesID);
histogramSeries.setPoints(points);
histogramSeries.update(histogramSeries);
points is an array of Point objects (Point[]).
Last edit: Joanna 2017-04-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think the call to "update()" is what may be causing the problem there. Try just using "histogramSeries.setPoints()" by itself, which will internally automatically apply and draw the new points to the series in the chart. (Note that are also overloaded versions of "setPoints()" available that will allow you to control when the chart is redrawn if you're updating many series at once.)
The "Series.update()" method is a newer method that is intended for a different use case (specifically for updating the render configuration options for the series after the series has been rendered). We'll get a ticket logged to check into ensuring that use of the "update" method is compatible with use of the "setPoints" method, but for your use case I think all you'll need is the "setPoints" method anyways.
Let us know if that clears up your use case!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm, coming back to this issue, as it seems that in another plot I do need the update() method. I set points as before (series.setPoints(Point [])) and would like to additionally change the series name - which should be updated in the legend. Without the update() method, the legend displays old series name, and with update(), the plot itself doesn't update...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also noticed that after invoking series.setPoints(Point[]) in this way (when it is called second or later time), series.getPoints() returns an empty array.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use a chart with one series which I need to update with different points on user's action (the chart is a histogram, and the user changes the step - influencing this way the number of bins). As a start I calculate the initial points, add them to the series - with series.setPoints(Point[])) - and add series to the chart - this works OK. When the user changes the parameters, I recalculate the points, use chart.getSeries(seriesId) to retrieve the series and on the retrieved series set the recalculated points - again with series.setPoints(Point[]). This works fine - the plot updates correctly, but if I do it only once (this is strange that it works once and not again), but if I do it for the second time the plot doesn't update.
If I do the same by removing points one by one (with series.removePoint(Point)) and then add the new points one by one (with series.addPoint(Point)) everything works fine every time. However, I prefer the setPoints method as it works more efficiently.
Hmm, that does sound odd. We use setPoints() regularly here for most of the charts in GWT applications that support dynamic updates, and haven't noticed this kind of an issue. Can you boil this does to a smaller code example/use case that you can post here so that we can take a closer look to see what may be going wrong?
Sorry for the late reply, but I haven't noticed your answer until today.
Taking the relevant part from my code, it looks like the example below:
This works:
This doesn't work (works only once):
points
is an array ofPoint
objects (Point[]
).Last edit: Joanna 2017-04-25
I think the call to "update()" is what may be causing the problem there. Try just using "histogramSeries.setPoints()" by itself, which will internally automatically apply and draw the new points to the series in the chart. (Note that are also overloaded versions of "setPoints()" available that will allow you to control when the chart is redrawn if you're updating many series at once.)
The "Series.update()" method is a newer method that is intended for a different use case (specifically for updating the render configuration options for the series after the series has been rendered). We'll get a ticket logged to check into ensuring that use of the "update" method is compatible with use of the "setPoints" method, but for your use case I think all you'll need is the "setPoints" method anyways.
Let us know if that clears up your use case!
It seems that without the update() method it works.
Thanks,
Last edit: Joanna 2017-04-27
Hi,
I'm, coming back to this issue, as it seems that in another plot I do need the update() method. I set points as before (series.setPoints(Point [])) and would like to additionally change the series name - which should be updated in the legend. Without the update() method, the legend displays old series name, and with update(), the plot itself doesn't update...
I also noticed that after invoking series.setPoints(Point[]) in this way (when it is called second or later time), series.getPoints() returns an empty array.
I know I am asking this very late, but by any chance did you get the solution or work around?