Why can't I update a chart on the proper way? Add one first, delete the las


I have generated a simple chart.

public class LineChart extends AbstractChart {

	private static final long serialVersionUID = 1L;

	private Chart chart;

    public void initDemo() {
        chart = new Chart();

        Configuration configuration = chart.getConfiguration();

        configuration.setTitle("Analog signals");

        YAxis yAxis = configuration.getyAxis();

        Legend legend = configuration.getLegend();
        // Add 20 data points
        configuration.addSeries(new ListSeries("ADC0", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
        configuration.addSeries(new ListSeries("ADC1", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
        configuration.addSeries(new ListSeries("ADC2", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
        configuration.addSeries(new ListSeries("ADC3", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
        configuration.addSeries(new ListSeries("ADC4", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
        configuration.addSeries(new ListSeries("ADC5", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));


And I pick up the object chart in another class. I want to chenge the ListSeries object inside chart.

// Get the series from the chart too
@SuppressWarnings("unchecked") // Need to have this due to the cast (ListSeries)
ADC0 = (ListSeries) lineChart.getChart().getConfiguration().getSeries().get(0);
ADC1 = (ListSeries) lineChart.getChart().getConfiguration().getSeries().get(1);
ADC2 = (ListSeries) lineChart.getChart().getConfiguration().getSeries().get(2);
ADC3 = (ListSeries) lineChart.getChart().getConfiguration().getSeries().get(3);
ADC4 = (ListSeries) lineChart.getChart().getConfiguration().getSeries().get(4);
ADC5 = (ListSeries) lineChart.getChart().getConfiguration().getSeries().get(5);

When I change the list series inside chart object, then it looks like this.

, true, true); // Update updateChartImmediately = true, shift to left = true
, true, true);
, true, true);
, true, true);
, true, true);
, true, true);

Then my chart looks like this. At the beginning I have 20 points, all zeros.

And after few seconds, The chart looks like this.

Isn’t it meant that this .addData(Number, updatedirectly, shift) should add a number to the ListSeries and then remove the first one? As I see, only the 20th number will be replaced with the latest number, while the ListSeries become smaller and smaller.

How can I solve this?


Nobody knows?

I try to ask again. No body? :slight_smile:
I assume then that is not possible to change the data series by just remove the first element and then add an element.

Daniel Mårtensson:
I assume then that is not possible to change the data series by just remove the first element and then add an element.

I would love to help you, but I don’t have hands on experience with Vaadin charts.

That you didn’t get a reply here in 4 weeks does not mean that it’s not possible, or anything really. Sadly, there aren’t too many community members like me, actively trying to help others without having the same problem as well. And the official vaadin developers aren’t obligated to answer each question here either.

Asking a question here in the forum might be a great first step when having a problem, but you will often find that a question here is forgotten.
The second step is now to consult the expert chat if you have access to that, or if you are pretty much certain that the actual behaviour is not how it is supposed to work, then you could directly open an issue in the right github repo.

Sorry for not being able to help. Don’t give up