How write inline if condition inside pie series in pie chart?

242 Views Asked by At

Im trying to change colour according to Label value in pie series.Im trying to write a inline if condition inside pie series like this

<mx:PieSeries
                    id="s1"
                    field="Value" 
                    nameField="Label" 
                    color="{'Value'='Other'?0xd8d8d8:colorArr}">                

</mx:PieSeries>

this is my data source to pie chart.data source length is not fixed. it will change dynamically.so i cant passs colour array by hard coding particular colour to other label field.Thats why im tying to write if condition inside pie series.

This is a sample data source

var expenses:ArrayCollection = new ArrayCollection([
                {Label:"Taxes", Value:1001},
                {Label:"Rent", Value:1005},
                {Label:"Bills", Value:1008},
                {Label:"Car", Value:1009},
                {Label:"Gas", Value:1020},
                {Label:"Food", Value:1015},
                {Label:"Other", Value:1080}  
            ]);

This is my colour array

private var colorArr:Array = new Array(
            "0x1ad6ef",
            "0xee816d",
            "0xfdd849",
            "0xff9e5d",
            "0xa4c286",
            "0xca6353",
            "0xd69b99",
            "0xe67976", 
            "0xfe9ae3",
            "0x6965b8", 
            "0xfebf9a",
            "0xfeb548"
        );

Is this possible guys ?

1

There are 1 best solutions below

1
On

Can you try this:

 color="{'Value'=='Other'?0xd8d8d8:0xffffff}"