We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Add series to Accumlation Pie Chart

Hi,

I need to add a series to a pie chart dynamically. Could anyone please assist me on the matter.

Regards

1 Reply

DD Dharanidharan Dharmasivam Syncfusion Team March 18, 2019 07:27 AM UTC

Hi Rikard, 
 
Greeting from Syncfusion.  
 
We have analyzed your requirement. Your requirement can be achieved by initializing the empty series and then you can add the series dynamically. Find the code snippet below to achieve this requirement. 
 
 
<ejs-accumulationchart id="pieChart"> 
            <e-accumulation-series-collection> 
                Initialized the empty series 
                <e-accumulation-series></e-accumulation-series> 
            </e-accumulation-series-collection> 
        </ejs-accumulationchart> 
 
function addSeries(args) { 
        var chart = document.getElementById('pieChart').ej2_instances[0];   
        var seriesData = { type: 'Pie', dataSource: [{ x: 'X1', y: 14 }, 
                                         //... 
                                        ], xName: 'x', yName: 'y' 
                                     }; 
        Assign the properties to chart from your data source and refresh the chart 
        chart.series[0].dataSource = seriesData.dataSource; 
        //... 
        chart.refresh(); 
    } 
 
 
 
Thanks, 
Dharani. 


Loader.
Live Chat Icon For mobile
Up arrow icon