Pie chart colors applied to [COLOR] and switch expression result

@tony @morgan @Aleksi Iโ€™m having trouble with pie chart colors similar to the following post: [Pie chart colors! Is there a way to tie spec]

However, rather than using an ENUM column, Iโ€™m using a COLOR column with a single option โ€œGreenโ€ that renders as a checkbox in a form. An IF expression changes the color of a STATUS column (box checked = GREEN, box unchecked=RED) and a switch expression is used to create more meaningful labels for the chart legend - SWITCH([DAILY], โ€œGreenโ€, โ€œcompleteโ€, โ€œRedโ€, โ€œnot doneโ€, โ€œโ€).

I would like for the โ€œGreenโ€ (or โ€œcompleteโ€, after the switch expression) to be rendered in the green color in the pie chart and โ€œRedโ€ (or โ€œnot doneโ€) to be red in the pie chart. However, as in the referenced post, the pie chart colors seem to be applied in descending order as configured in the UX/Chart/View Options/Chart Colors rather than applied strictly by category.

Any suggestions? Thanks in advance!

Solved Solved
0 6 2,327
1 ACCEPTED SOLUTION

It will display in alphabetical order but when there is no data for a category it will skip that one, so for example if all of your statuses are โ€œNot Doneโ€ it will incorrectly use the first color instead of the second. There is no way to set the color dynamically like you want (but that seems like a reasonable feature request).

To workaround this, I recommend you change your label type to an enum and be sure to add the two options: โ€œCompleteโ€, โ€œNot Doneโ€ then the color order should always match even when one of the categories is empty.

Like this:

View solution in original post

6 REPLIES 6

Any thoughts on this inquiry?

As far as I know, chart column colors are ordered alphabetically based on the label column. So in your case you should be able to use your label column with โ€œGreenโ€ followed by โ€œRedโ€ in your aggregate pie chart, because โ€œcompleteโ€ is before โ€œnot doneโ€ alphabetically.

The color column is not used directly in this case (only to compute your label column) and color is determined by that the order specified in the aggregate pie chart view.

If doesnโ€™t work, let me know, Iโ€™m happy to follow-up on this.

@nico, apologies for the late response, I didnโ€™t see your post come through. My understanding is the same as yours - alphabetical order. However, that is not the behavior Iโ€™m seeing in my app - at least not at the start of the day. At the start of the day, our daily tasks havenโ€™t been done yet, so I would expect to see a pie chart that is all red in color and labeled โ€œnot doneโ€. Instead, I see a pie chart that is all green in color and labeled โ€œnot doneโ€.

As tasks are completed and both โ€œcompleteโ€, and โ€œnot doneโ€ appear on the graph then the colors and labels match up.

Any thoughts? again, apologies for the very late reply.

It will display in alphabetical order but when there is no data for a category it will skip that one, so for example if all of your statuses are โ€œNot Doneโ€ it will incorrectly use the first color instead of the second. There is no way to set the color dynamically like you want (but that seems like a reasonable feature request).

To workaround this, I recommend you change your label type to an enum and be sure to add the two options: โ€œCompleteโ€, โ€œNot Doneโ€ then the color order should always match even when one of the categories is empty.

Like this:

@nico thanks! Enum column type works a treat. Why does this work and text columns doesnโ€™t?

The reason is with that a enum has the complete list of statuses whereas the text type it guesses by looking at the data in the spreadsheet. When they are all the same it will assume there is just one status when there are in fact two but one of them (โ€œcompleteโ€) has 0 entries.

At any rate, Iโ€™m glad this worked for you!

Top Labels in this Space