Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    12
    Vote Rating
    0
    Answers
    1
    nm1 is on a distinguished road

      0  

    Default 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).

  2. 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?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,652
    Vote Rating
    901
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    No, you are only able to use the array like you have
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    12
    Vote Rating
    0
    Answers
    1
    nm1 is on a distinguished road

      0  

    Default


    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?