Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
DataSeries Update single value in chart
I'm trying to update dinamically a Column Chart (vaadin charts 3.0.0) populated with a DataSeries.
I cannot find a way to do it, unless redraw the chart completely. This solutions is not possible becouse the column will redrawn with an un-wanted animation from zero to the new value. I would like that the column animates only from the previous value to the next value.
This is possible if I use the ListSeries.
In such class I have an API to update the value of a point:
updatePoint(int pointIndex, Number newValue)
which do this work.
But in DataSeries, using this pattern seems not possible, becouse the dataseries returned is immutable, so the only solution is detroy the dataseries and recreating a new one.
Anyone has passed through the same situation?
Have you tried with DataSeries#update(...) method? It should allow you to modify a single data series item
Hope this helps,
Guille
Nope, or maybe I use it in a wrong way. This is my code:
for (DataSeries series : chartBlock.getColumnChartSeries()) {
series.get(0).setY(series.get(0).getY().doubleValue() + y);
series.update(series.get(0));
}
chartBlock is my CustomComponent in which i save an arrayList of Dataseries.
only if i add the line
chartBlock.getChartList().get(1).drawChart();
the chart will update its value, but this is not the expected behaviour
Hi Tiziano,
I did a really basic test with Vaadin 7 and Charts 3:
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
final DataSeries dataSeries = new DataSeries();
dataSeries.addData(new Number[][] { { 0, 1 }, { 2, 2 }, { 10, 3 } });
conf.setSeries(dataSeries);
Button button = new Button("Update Point");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
DataSeriesItem item = dataSeries.get(1);
item.setY(30);
dataSeries.update(item);
}
});
And it works as expected. I even tried with multiple charts and updating multiple series and it seems to work. Can you test this basic example in your project and in an empty project? That could help figuring out what could be going wrong.
Hope this helps,
Guille
Sorry, Guillermo, you are right and the api works fine.
It was my fault. In certain circumstances my method returned the wrong DataSeries.
I'vo solved this and now the charts update correctly.