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

Hi!

I have generated a simple chart.

@Getter
public class LineChart extends AbstractChart {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Chart chart;

	@Override
    public void initDemo() {
        chart = new Chart();
        chart.setWidth("1027px");
        chart.setHeight("768px");

        Configuration configuration = chart.getConfiguration();

        configuration.setTitle("Analog signals");
        configuration.setSubTitle("jlogger");

        YAxis yAxis = configuration.getyAxis();
        yAxis.setTitle("Measurements");

        Legend legend = configuration.getLegend();
        legend.setLayout(LayoutDirection.VERTICAL);
        legend.setVerticalAlign(VerticalAlign.MIDDLE);
        legend.setAlign(HorizontalAlign.RIGHT);
        
        // 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));

        add(chart);
    }
}

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.

ADC0.addData(adcValues[0]
, true, true); // Update updateChartImmediately = true, shift to left = true
ADC1.addData(adcValues[1]
, true, true);
ADC2.addData(adcValues[2]
, true, true);
ADC3.addData(adcValues[3]
, true, true);
ADC4.addData(adcValues[4]
, true, true);
ADC5.addData(adcValues[5]
, 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?

18033567.png
18033570.png

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
Cheers