Get colors of all the series in the chart

Hello,

How do I get the colors of all the series/lines in the chart. 
For example in the below chart how to get the list of  all the colors( i.e green, black, blue)



3 Replies

BP Baby Palanidurai Syncfusion Team March 15, 2018 07:08 AM UTC

Hi Manu, 

Thanks for using Syncfusion products. 

We have analyzed your query. Your requirement can be achieved as a workaround using the loaded event. In the loaded event by using interior property in the series, we can get the series color. Please find the below code to achieve your requirement, 


import { ILoadedEventArgs, Series } from '@syncfusion/ej2-ng-charts'; 

public loaded(args: ILoadedEventArgs): void { 
        let colors: string[] = []; 
        for (let series of <Series[]>(args.chart.series)) { 
           colors.push(series.interior); 
        } 
        alert(colors); 
    }; 

Screenshot: 
 
We have prepared a sample based on this. Please find the sample from below link, 

Kindly revert us, if you have any concerns. 

Thanks, 
Baby. 



MA Manu March 15, 2018 07:54 AM UTC

Thank you, it worked


BP Baby Palanidurai Syncfusion Team March 16, 2018 09:58 AM UTC

Hi Manu, 

Thanks for your update, 

Please let us know if you need any further assistance on this. 

Regards, 
baby

Loader.
Up arrow icon