-
15 Sep 2012 7:16 PM #1
Answered: Applying specific colors to pie slices
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?
-
17 Sep 2012 9:31 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3104
No, you are only able to use the array like you have
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Sep 2012 6:07 AM #3
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?
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote