Hello
A user is having some strange behaviour when trying to change a bar charts column colours.
They have a SharePoint list with a single line of text column called "Status"
SharePoint records are loaded into a collection (Ive also tried pointing the chart directly to the SharePoint list) -
ClearCollect(Records,
'SharePoint List'
);
The bar chart 'Items' is set to -
AddColumns(
GroupBy(
Records,
"Status",
"SubGrp"
),
"Count",
CountRows(SubGrp)
)
The bar chart ItemColorSet is set to -
ForAll(
Records,
Switch(
Status,
"complete",
Color.Blue,
"on track",
Color.Green,
"delayed",
Color.Red,
"Paused",
Color.Purple,
Color.Black
)
)
But all the columns show as the colour blue, matching the "complete" records color. If i remove "complete" from the formula -
ForAll(
Records,
Switch(
Status,
"on track",
Color.Green,
"delayed",
Color.Red,
"Paused",
Color.Purple,
Color.Black
)
)
All the columns are then black.
If i exclude any records that equal "complete" when populating the collection -
ClearCollect(
List,
Filter(
'SharePoint List',
Status <> "complete"
)
);
Then all the remaining columns are coloured correctly as per the switch formula.
The only difference is theres 26 records that equal "complete" and only 1 of the other types but can't see why that would make a difference.
Any ideas?
Thanks
Solved! Go to Solution.
The order of the color records in the ItemColorSet must match and be in the same order and same number of records as the Items of the chart.
This can also be done without a collection.
Do the following steps:
1) Add a new SCROLABLE screen to your app. On that screen, select the Canvas control that is created on it. Resize to be very small and then ctrl-X (cut) it from the screen.
2) Delete the new screen you just added.
3) Back on your other screen, paste the canvas you just cut from the other new screen.
NOTE: you are creating what I call a dynamic variable. You can keep it on a separate screen, but I like to have these in context of where they are used.
Now, I will assume that the canvas is Canvas1 and the DataCard in it is DataCard1 if not substitute as needed.
1) Go to DataCard1 and then choose the Update property.
2) In the Update property, but the following formula:
{
ChartItems:
AddColumns(
GroupBy('SharePoint List',
"Status",
"SubGrp"
),
"Count", CountRows(SubGrp),
"_color",
Switch(Status,
"complete", Blue,
"on track", Green,
"delayed", Red,
"Paused", Purple,
Black
)
)
}
Now, in the Items property of your Chart : DataCard1.Update.ChartItems
And in the ItemColorSet property : ForAll(DataCard1.Update.ChartItems, {Value: _color})
You will now have a dynamic (will change as underlying list values change) chart with the proper colors.
I hope this is helpful for you.
The order of the color records in the ItemColorSet must match and be in the same order and same number of records as the Items of the chart.
This can also be done without a collection.
Do the following steps:
1) Add a new SCROLABLE screen to your app. On that screen, select the Canvas control that is created on it. Resize to be very small and then ctrl-X (cut) it from the screen.
2) Delete the new screen you just added.
3) Back on your other screen, paste the canvas you just cut from the other new screen.
NOTE: you are creating what I call a dynamic variable. You can keep it on a separate screen, but I like to have these in context of where they are used.
Now, I will assume that the canvas is Canvas1 and the DataCard in it is DataCard1 if not substitute as needed.
1) Go to DataCard1 and then choose the Update property.
2) In the Update property, but the following formula:
{
ChartItems:
AddColumns(
GroupBy('SharePoint List',
"Status",
"SubGrp"
),
"Count", CountRows(SubGrp),
"_color",
Switch(Status,
"complete", Blue,
"on track", Green,
"delayed", Red,
"Paused", Purple,
Black
)
)
}
Now, in the Items property of your Chart : DataCard1.Update.ChartItems
And in the ItemColorSet property : ForAll(DataCard1.Update.ChartItems, {Value: _color})
You will now have a dynamic (will change as underlying list values change) chart with the proper colors.
I hope this is helpful for you.
Brilliant thankyou for such a detailed reply!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
198 | |
70 | |
49 | |
42 | |
30 |
User | Count |
---|---|
268 | |
119 | |
98 | |
92 | |
82 |