cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AB1
Helper IV
Helper IV

Changing colours on a pie chart

Hi all,

 

This may be quite simple but I cant figure out on how to change the slice colours in a pie chart any ideas?

 

Screenshot 2021-11-03 at 4.31.53 PM.png

3 REPLIES 3
RandyHayes
Super User
Super User

@AB1 

Colors are controlled by the ItemColorSet property.  It expects a table of color values. The order of the colors in that table correlates to the order of the items in your Items property.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes So it can be changed and I have to had in item property? Can even specify the slice colour? (if this makes sense)

RandyHayes
Super User
Super User

@AB1 

Your Items property is the data for the chart.  It will not contain colors.

The ItemColorSet is a table of colors that will govern how the slices look.

For example, this default pie chart and changing it's colors:

AB1.gif

To accomplish this is very simple.  The dropdown control in the image has an items property of:

Table(
    {Disp: "Original Colors", ColorSet:
           [RGBA(49, 130, 93, 1),RGBA(48,166,103, 1), RGBA(94,193,108,1), 
            RGBA(246,199,144,1), RGBA(247,199,114,1), RGBA(247,180,91,1), 
            RGBA(246,143,100,1), RGBA(212,96,104,1), RGBA(148, 110, 176, 1), 
            RGBA(118, 154, 204, 1), RGBA(96, 197, 234, 1)]
    },
    {Disp: "Wild Colors", ColorSet: 
           [Red, Green, Yellow, Blue, DarkGreen, LightBlue, urple, DarkGray, 
            DarkMagenta, LightSteelBlue]
    },
    {Disp: "Crazy Colors", ColorSet: 
           [Magenta, Purple, DarkMagenta, Crimson, DarkOrchid, DeepPink, GreenYellow,
            MediumSpringGreen, SlateBlue, Yellow]
    }
)

You will see in this that the first record "Original Colors" has a column called ColorSet that is a table of all the colors that were found in the default PieChart.

The second and third records just have different names and ColorSet tables.

 

For the Pie Chart, the ItemColorSet is set to: drpColorSelector.Selected.ColorSet  (where drpColorSelector is the name of the Dropdown mentioned above).

 

That is all there is to it!

 

So, you obviously don't need a dropdown to change colors and this was JUST a demonstration, but the key point here is that the ItemsColorSet table determines the colors used in the Pie Chart.  The order of the colors in the table will correspond to the order of the items in the table supplied to the Items property of the Pie Chart.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,551)