Thank you for reporting this bug. We will make it our priority to review this report.
-
Sencha User
Answered: Applying specific colors to pie slices
I have a requirement to associate a specific color to a pie slice. This information is retrieved from the server along with the charting data.
I have already tried setting colorSet to the list of colors. This works most of the time, except if one of the slices have a '0' value associated with it. Using this example http://dev.sencha.com/deploy/touch-c.../examples/Pie/ as reference, lets say here is what needs to be plotted -
Month, Value, Color
Jan, 10, #aaaaaa
Feb, 20, #bbbbbb
Mar, 0, #cccccc
Apr, 30, #dddddd
colorSet = [#aaaaaa, #bbbbbb, #cccccc, #dddddd]
Since value=0 for Mar, Apr getting filled with #cccccc.
Is there a way to decide which color to select at the time of drawing rather than when the object is created? Looking at the piechart code, it would be good to have a 'getPieSliceColor' method that I could override (similar to the getLegendColor method).
-
Best Answer Posted by
nm1
Ok I figured out what was going on. In my store, I have specified a sorter which orders the data.
I was setting colorSet by iterating over Ext.getStore('blah').data.all and extracting the color. This data was not sorted!!
I wrote a function to sort the data before setting the colorSet and now it works fine.
Question - Is there a way to extract data from the store in sorted order? I see there is a sort() function in the Store class, but does that change the underlying data or just return a sorted copy of the data?
-
No, you are only able to use the array like you have
-
Sencha User
Ok I figured out what was going on. In my store, I have specified a sorter which orders the data.
I was setting colorSet by iterating over Ext.getStore('blah').data.all and extracting the color. This data was not sorted!!
I wrote a function to sort the data before setting the colorSet and now it works fine.
Question - Is there a way to extract data from the store in sorted order? I see there is a sort() function in the Store class, but does that change the underlying data or just return a sorted copy of the data?