Delete the previous series

Hey i used your widget to create line series in my Angular Project.
I used the following method to create the dynamic series.

this.chart.addSeries([{

dataSource: this.dataSourceObj,
xName: 'x', width: 2,
yName: 'y' ,
marker:{
visible: true,
height: 10,
width: 10
}
}]);

My requirement is to show the series of the selected user, but after selecting the first user series displays correctly but when i select the second user instead of showing me the 2nd user series only the chart shows the both user series. I want to delete the series of the previous user or any user's series before rendering the series of the current user how can i do that?


1 Reply

BP Baby Palanidurai Syncfusion Team March 12, 2018 08:34 AM UTC

Hi Umer, 

Thanks for using syncfusion products, 

We have analyzed your query. As for your requirement we have prepared a sample for delete previous series while select to add new series. Kindly find the code snippet below to achieve this requirement.  
HTML 

<ejs-chart #chart id='chartcontainer' > 
            <e-series-collection> 
                <e-series [dataSource]='data' type='Column' xName='x' yName='y' > </e-series> 
            </e-series-collection> 
    </ejs-chart> 
    <button ejs-button class='e-flat' (click)='add1()'>add series1 </button> 
    <button ejs-button class='e-flat' (click)='add2()'>add series2</button> 

TS 

add1() { 
                this.chart.series = []; 
                this.chart.addSeries([{ 
                type: 'Column', fill: ‘red’, 
                dataSource:data1, xName: ‘x’, 
                yName: 'y', marker: this.marker 
            }]); 
        } 
         add2() { 
                this.chart.series = []; 
                this.chart.addSeries([{ 
                type: 'Column', fill: ‘blue’, 
                dataSource: data2, 
                xName: 'x', width: 2, 
                yName: 'y',  marker: this.marker 
            }]); 
        } 

Screenshot: 
 

Sample for your reference can be find from below link, 

Kindly revert us, if you any concerns. 

Thanks, 
Baby. 


Loader.
Up arrow icon