Invient Charts - removeAllPoints doesn't seem to fully work

Hi,

First - excellent work! Invient Charts is amazing!

I have a problem though: I have a spline chart which I am updating in a background thread. As long as I’m just adding points to the series, everything works great. However, when I want to remove all existing points from the series (via ‘removeAllPoints’ method), and add new points, the old points are still visible in the chart.

Here is a how I create the chart:


InvientChart chart = new InvientChart( new InvientChartsConfig() );
chart.getConfig().getTitle().setText( title );
chart.getConfig().getGeneralChartConfig().setSpacing( new Spacing( 30, 30, 30, 30 ) );
chart.getConfig().getGeneralChartConfig().setShadow( true );
chart.setSizeFull();
chart.setHeight( "500px" );
chart.getConfig().getGeneralChartConfig().setShadow( false );

InvientChartsConfig.DateTimeAxis xaxis = new InvientChartsConfig.DateTimeAxis();
xaxis.setShowFirstLabel( false );
chart.getConfig().addXAxes( xaxis );

InvientChartsConfig.NumberYAxis yaxis = new InvientChartsConfig.NumberYAxis();
yaxis.setTitle( new InvientChartsConfig.AxisBase.AxisTitle( "" ) );
chart.getConfig().addYAxes( yaxis );
yaxis.setMin( 0.0 );

DateTimeSeries series = new DateTimeSeries( "Used", InvientCharts.SeriesType.SPLINE, new InvientChartsConfig.SeriesConfig(), true );
chart.addSeries( series );

And that’s what I’m doing in the background thread:


synchronized(getApplication()) {
    //
    // if the user selected a different data set in the combo-box, remove data from the previous data-set
    //  
    InvientCharts.DateTimeSeries s = ( InvientCharts.DateTimeSeries ) chart.getSeries( "Used" );
    if( userSelectedDifferentDataSet ) { 
        s.removeAllPoints();
    }

    //
    // add new point from the correct data-set (if user changed selection, previous data has been removed by code-section above)
    //
    s.addPoint( new InvientCharts.DateTimePoint( s, new Date(), newPointValue ), true );
}

Any help is appreciated - thanks!

I think you are creating a copy of the DateTimeSeries and just remove all points from that copy and not from the actual shown series.

This should work for you : ((DateTimeSeries)chart.getSeries("Used")).removeAllPoints();

If you use this instead of using the Object s you directly manipulate the shown series.