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

Pie Chart Series palette.

Hi,

I'm trying to get a double pie chart working, as in your example here. It works, but I need to provide custom color palettes to each series.

I saw this sample, where I can provide a custom color palette on the <ej-chart> tag, but that applies to both my series. I need to have different color palettes for the two series.

So is there a similar way to pass palette color arrays to series?

Thanks,

Alex


1 Reply

DD Dharanidharan Dharmasivam Syncfusion Team April 21, 2017 09:12 AM UTC

Hi Alexandru, 

Thanks for contacting Syncfusion support. 

We have analyzed your query. We would like to let you know the behavior of palette property. For multiple pie series, if colors are specified in palette property, then it will be applied to each point in a series. To achieve your requirement, we would suggest you to initialize an array with desired colors and then specify the colors in the seriesRendering event to the fill property in points as highlighted in below code snippet. 

Angular 2:  

<ej-chart (seriesRendering)="seriesRender($event)"> </ej-chart> 
 
TS: 
seriesRender(sender) { 
        let chart = $("#multipie").data("ejChart"); 
 
   //Getting Series index 
        let seriesIndex = $.inArray(sender.data.series, chart.model._visibleSeries); 
        let points = sender.data.series.points; 
        let palette = ['#4286f4', '#00cc00', '#666633']; 
 
        for (let i = 0; i < points.length; i++) { 
            //Based on series index specify the colors 
            sender.data.series.points[i].fill = palette[seriesIndex]; 
        } 
 
    } 

Screenshot: 
 

Sample for reference can be find from below link. 
 
Thanks, 
Dharani. 


Loader.
Live Chat Icon For mobile
Up arrow icon