Vaadin Charts 2.1 SNAPSHOT: Dynamic update to x-axis categories and series

private void populateData(String cat, int data) {
// series data
for (int i = 0; i < data.length; i++) {
if (i == 0) {
// reduce the series data to 1
} else {

private void printSeriesData() {
String cat = chart.getConfiguration().getxAxis().getCategories();
int i = 0;
for (Number n : series_h.getData()) {
System.out.printf(“%s::%d “, cat[i++]
, n.intValue());
[/code]I am trying to build a dynamic UI, where the x-axis categories and the series data are fetched from a backend service. There 3 series defined - HIGH / MEDIUM / LOW.

The model is getting updated with right values, but the first element in the UI is not updated, also the x-axis categories names are updated.

This is a standard usecase for dynamic query dashboard. What is best way to go about this ?


NOTE: If I redraw chart, all the model values are updated collectly on the UI. But, this is not the expected behavior, redraw created unnecessary animations.


updates the UI with the right values. Is this a bug ?

Hi Alan,

What implementation of series are you using?

In case it’s DataSeries the setData and addData methods will not update a chart that is already displayed. To do that you should use the add method that will fire a dataAddedEvent to update client-side chart, there’s an overload of this method that allows data shifting to replace old values. Also the remove method will update the displayed chart.

Otherwise you can use setData and addData and then redraw the chart with drawChart as you mentioned. this method will animate the chart if animations are enabled as you noticed.

Hope this helps!

Hi Guillermo,

Thanks for taking your time.

I am using ListSeries instances. I tired the method you suggested. Looks like it is firing the dataAddedEvent.
addData(23, true, false);

public void addData(Number number, boolean updateChartImmediately, boolean shift) The documentation for this method, seems confusing - what is the purpose of updateChartImmediately = false ? does is cache the data, and update the chart on the next request ?

I have another query regarding ListSeries, how do you clear all the data in it ?

There is no method like series.clear() similar to DataSeries.



False in updateChartImmediately is useful if you wan’t to update the data but don’t want the change to be immediate, you can update the data and on the next drawchart() data will be updated.

Regarding how to clear in ListSeries right now the only option is to use setData method but it will require a manual drawchart(), if you want to suggest some new API you can create a ticket in
for ListSeries.clear API for instance.