cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Power Apps Staff tahoon
Power Apps Staff

Re: BUG REPORT: Pie chart color problems

For your information, this pie chart color bug has been fixed. Let us know if you still experience issues!

Sienna
Level 10

Re: BUG REPORT: Pie chart color problems

@tahoon

So far the pie chart has still wrong colors. Let me republish it to see if that'll help

Sienna
Level 10

Re: BUG REPORT: Pie chart color problems

@tahoon

Yes it looks like it works properly now... Thanks

Anonymous
Not applicable

Nope - still not working properly.

Colour charts seem to be working ok, except where the data-set is reduced to less than the full set of options:

 

Using the following works fine for a full dataset, but as soon as you filter the dataset such that you don't have the full spectrum of results, PowerApps has absolutely no idea what it's doing.

 

ForAll('MyDataset',
    Switch(
        Priority,
        "High", Red,
        "Medium", Orange,
        "Low", Green
    )
)

PowerApps Priority.JPGFull DataSetPowerApps Priority - Broken 2.JPGPartial DataSet 1PowerApps Priority - Broken.JPGPartial DataSet 2

Power Apps Staff tahoon
Power Apps Staff

Re: Nope - still not working properly.

Hi @Anonymous, the way that ItemColorSet works is that the first color will be assigned to the first available option, the second color will be assigned to the second available option, and so on. The colors are not permanently linked to a particular option.

 

Think about the opposite scenario: what if there are more options that colors in the color set? In that case, the colors will cycle.

 

To display consistent colors for options, like in your example, instead of filtering out entire options, leave them but set their value to 0. Example:

 

 

High: 0,

Medium: 0,

Low: 20

Anonymous
Not applicable

Re: Nope - still not working properly.

@tahoon thanks for the reply.

 

Sorry, I don't think that's correct.

 

If I change the order of my select statement, I still get the same results. Note the following result with the select statement in a different order:

 

ForAll('MyDataset',
    Switch(
        Priority,
        "Low", Green,
        "Medium", Orange,
        "High", Red
    )
)

 

PowerApps - Broken 3.JPGStill not working

 

Even if it was correct, it's completely unintuative. If I'm using a select statement and say High is Red, then High should always be Red, they should never cycle. Otherwise I'd just use a simple colour set and let PowerApps pick it for me.

Power Apps Staff tahoon
Power Apps Staff

Re: Nope - still not working properly.

What are the values for ItemColorSet and Items in the PieChart? That might clear things up.

 

Here is the simplest example of how PieChart should be set up to display 2 counts of High, 4 for Medium, and 10 for Low.

 

 

Items = Table({Label:"High", Value: 2}, {Label:"Medium", Value: 4}, {Label:"Low", Value: 10})
Labels = Label
Series = Value
ItemColorSet = [Red, Orange, Green]

The resulting chart uses Red for High, Orange for Medium, Green for Low.

 

 

To just show Low values and keep it green in the chart, this is the best way to do it:

 

Items = Table({Label:"High", Value: 0}, {Label:"Medium", Value: 0}, {Label:"Low", Value: 10})
ItemColorSet = [Red, Orange, Green]

Or,

Items = Table({Label:"Low", Value: 10})
ItemColorSet = [Green]

 

If there are less colors than options like this:

Items = Table({Label:"High", Value: 2}, {Label:"Medium", Value: 4}, {Label:"Low", Value: 10})
ItemColorSet = [Red, Orange]

Then resulting chart uses Red for High, Orange for Medium, Red for Low. The colors cycle.

 

Anonymous
Not applicable

Re: Nope - still not working properly.

I think we're talking two slightly different things here - as you can see, I'm using a select statement on my ItemColorSet, not just a simple set of colours.

 

Nevertheless, I've created a new test dataset to illustrate the issue. Note that priority is a choice field, which PowerApps cannot handle, so PriorityValue is a calculated column equal to Priority, so I can use this in a PieChart:

 

PieTest Data.JPGPieTest Data

Chart formula for the chart:

 

AddColumns(GroupBy(PieTest, "PriorityValue", "Label"),"Count", CountRows(Label))

ItemColorSet formula:

 

ForAll('PieTest',
    Switch(
        PriorityValue,
        "Low", Green,
        "Medium", Orange,
        "High", Red
    )
)

Resultant Chart:

 

PieTest Chart.JPGPieTest Chart

...So, my first evaluation of the issue was wrong - it's not to do with filtering results or anything like that, it's just pure madness from PowerApps - if you can identify what I'm doing wrong here, I'd love to know, because all of this points to bugs in the application.

 

Thanks for your help

 

Power Apps Staff tahoon
Power Apps Staff

Re: Nope - still not working properly.

Thanks for providing an example. I will try my best to explain.

 

ItemColorSet is not related to the Items in the pie chart. ItemColorSet is simply used to specify the first pie slice color, the second pie slice color, and so on. It is not aware of data inside Items. The Labels of Items will determine which is the first pie slice, the second pie slice, and so on.

 

In your example, AddColumns(GroupBy(PieTest, "PriorityValue", "Label"),"Count", CountRows(Label)) will evaluate to

 

{ PriorityValue: "Medium", Count: 2 },
{ PriorityValue: "High", Count: 1 },
{ PriorityValue: "Low", Count: 1 }

I assume Labels is set to PriorityValue. Therefore, the first pie slice will represent "Medium", the second represents "High", and the last represents "Low".

 

Next, ForAll('PieTest',Switch(...)) will evaluate to

[ Orange, Orange, Red, Green ]

 

Therefore, the first pie slice color will be orange, the second will be orange, the third will be red, and last will be green. Since there are only 3 pie slices used, the last color (green) is not used. The pie chart in your screenshots is actually the expected result.

 

If you want a color to always represent a particular PriorityValue, you have to ensure that the data in Items are in the correct order. For example, set ItemColorSet=[Red, Orange, Green] and have Items such that the first category will be High, second will be Medium, and third will be Low. One way to do that is to map PriorityValue to numbers and sort the table to look like this:

{ PriorityValue: "High", Count: 1 },
{ PriorityValue: "Medium", Count: 2 }, { PriorityValue: "Low", Count: 1 }

 

Anonymous
Not applicable

Re: Nope - still not working properly.

Right, thanks - I see what you mean.

 

Is there a way to specify specific colours for pie chart slices, based on their label, or are we outta luck here?

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,841)