Results 1 to 3 of 3

Thread: Applying specific colors to pie slices

Hybrid View

Previous Post Previous Post   Next Post Next Post
    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
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    No, you are only able to use the array like you have
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    12
    Answers
    1
    Vote Rating
    0
      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?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •