[vaadin chart] how to remove all DataSeriesItem from a series

Hi,

I try to remove the data points interactively. Code is :

DataSeries tmp = (DataSeries)s;

if(tmp.size() > 0 && ctrlKey == false){

Iterator<DataSeriesItem> iter = tmp.getData().iterator();

while(iter.hasNext()){

DataSeriesItem obj = iter.next();

if(obj != null)

iter.remove();

}

}

This will throw the operation unsupport exception because the getData() returns a unmodifiableList, why is that? How can I remove items from the List from the the chart?

Br,
Xuan

found series.Clear(), I admit I am surprisingly happy at that moment, but then found it does not work the second minute.

DataSeries tmp = (DataSeries)s;

if(tmp.size() > 0 && ctrlKey == false){

tmp.clear();

}

tmp.add(mark);
DataSeries tmp = (DataSeries)s;

if(tmp.size() > 0 && ctrlKey == false){

for(int i = 0; i < tmp.size(); i++)

tmp.remove(tmp.get(0));

}

tmp.add(mark);

Solution is here:

DataSeries tmp = (DataSeries)s;

if(tmp.size() > 0 && ctrlKey == false){

while(tmp.size() > 0){

tmp.remove(tmp.get(0));

}

}

tmp.add(mark);

For anyone looking at removing a DataSeries, this was my approach (right or wrong):

public void removeListSeries(String seriesName)
    {
        List<Series> s = new ArrayList<Series>();
        // Use another list - the configuration sends an unmodifiable list, so initialize with a copy of it
        for (Series i : chart.getConfiguration().getSeries())
            s.add(i);
        
        for (int i=0;i<s.size();i++)
        {
            DataSeries ds = (DataSeries) chart.getConfiguration().getSeries().get(i);
            
            if (ds.getName().equalsIgnoreCase(seriesName))
            {
                s.remove(i);
                // Update the chart with the new list
                chart.getConfiguration().setSeries(s);
                chart.drawChart();
                break;
            }
        }
    }

Thanks Eric S. You made my day! Finally can remove the List Series and update the chart!

Thank you Eric S