Restricting plotted points on a line chart

i want something like the sample provideed here https://demo.vaadin.com/charts/#SplineUpdatingEachSecond
How do i achieve something similair?

[code]
Chart chart = new Chart();
chart.setHeight(“450px”);
chart.setWidth(“100%”);

    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);

    configuration.getTitle().setText("Monitoring");

    
    configuration.getxAxis().setType(AxisType.DATETIME);

    DateTimeLabelFormats dateFmt = new DateTimeLabelFormats();
    dateFmt.setSecond("%M:%S");
    configuration.getxAxis().setDateTimeLabelFormats(dateFmt);
    
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(0d);
    yAxis.setTitle(new AxisTitle("Percentage"));
    yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);


    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.getDataLabels().setEnabled(true);
    plotOptions.setThreshold(6);
    configuration.setPlotOptions(plotOptions);

    Legend legend = configuration.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.CENTER);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-10d);
    legend.setY(100d);
    legend.setBorderWidth(0);

    chart.drawChart(configuration);
    return chart;

[/code]setThreshold does not seem to be the right way to go

resolved it using shifting when adding an entry to a DataSeries

ls.add(new DataSeriesItem(time, percentage),true,true);