How to use custom palette in canvas dashboards

I have Pie charts showing Top 5 categories plus Other category, and have defined a custom color palette for this. I then define in the series as follows:

      series {
        field: VizFieldFull {
          label: 'Series'
          ref: ref('some_model', 'metric1')
          format {
            type: 'number'
            pattern: 'inherited'
          }
        }
        settings {
          color_palette: "Five Plus One"
        }
      }

My intent is for holistics to automatically assign the first five colours to the Top 5 categories and the last colour to the Other. I am able to set the color_palette value to the default palette names. Can we set the custom palettes as well?

Hi @shahidt,

Thank you for sharing your use case. You can apply any color palette to a specific chart in Visualization settings (in Block editor)

Expand the field in the Value section, you will see all categories:

Click on the color on the right of the category name:

Selecting a color palette (click on the color paletteā€™s label or radio button), the color palette will apply to all values

However, our color palette default is created to assign color to categories, not the order of the pie chart. In order to assign the first five colors to the Top 5 categories and the last color to the Other, you have to delete all mapping information in the code:


The final code would be:

I hope my reply is helpful to you. Dont hesitate to let me know if you need any further assistance or have any further questions.

@Tai_Nguyen I am using code editor in Canvas Dashboards. I do intend to use the color_palette property to set a palette, so the pie automatically sets the colours. However, it does not let me specify a custom palette. I am only able to specify the pre-built ones.

Hi @shahid, Iā€™d like to confirm a couple of points to better assist you:

  1. It seems you already know how to select a color palette for your chart, based on my previous instructions.
  2. Youā€™re looking to create or modify a custom color palette that can be applied to your chart, rather than relying solely on pre-built palettes.

If thatā€™s correct, you can create or update your own color palette by navigating to ā€‹Settings > More Settings > Chart Color Palettes ā€‹ in Holistics. For further guidance on this, please refer to our documentation on Color Palettes.

I hope this information is helpful. Please feel free to reach out if you have any further questions or need additional assistance.

@Tai_Nguyen I know how to create custom palettes and I had already created one. I am creating a Canvas Dashboard, using the code editor view, and not visually. In it, I have a Pie Chart visual, with the following series configuration:

      series {
        field: VizFieldFull {
          label: 'Revenue'
          ref: ref('sales', 'revenue')
          format {
            type: 'number'
            pattern: 'inherited'
          }
        }
        settings {
          color_palette: 'categorical'
        }
      }

The above code works, since ā€˜categoricalā€™ palette is pre-defined. However, the following doesnā€™t work, since the ā€˜Five Plus Oneā€™ palette was created by me. It doesnā€™t work, even if I define a name without any spaces.

      series {
        field: VizFieldFull {
          label: 'Revenue'
          ref: ref('sales', 'revenue')
          format {
            type: 'number'
            pattern: 'inherited'
          }
        }
        settings {
          color_palette: 'Five Plus One'
        }
      }

I get an error:

Incompatible property 'color_palette'.
  Type 'String' is not assignable to type 'ColorPalette'
-------------------------------------------------------------------------
Property color_palette (optional): "categorical" | "div-blue-red" | "div-teal-orange" | "seq-blue" | "seq-teal" | "seq-viridis" | "seq-magma"
-------------------------------------------------------------------------
No quick fixes available

Hi @shahidt, Thank you for your reply. After reviewing the details, our team has confirmed that it is indeed a bug on our end. We are actively working on a solution and will keep you updated with any progress.
We apologize for any inconvenience this has caused you and your team, and we appreciate your patience and understanding as we resolve this matter.

Hi @shahidt,
Iā€™m pleased to announce that we have released a patch that fixes the issue with the color palette selector in the Edit Report modal.
Thank you for bringing this to our attention and for your patience. If you have any further questions or need assistance, please donā€™t hesitate to reach out.

@Tai_Nguyen I was not able to try this sooner, but I still get an error. I created a new palette called ā€˜Five-Plus-Oneā€™ and then set it to the color_palette property like this:

      series {
        field: VizFieldFull {
          label: '​'
          ref: ref('fact_table', 'sales')
          format {
            type: 'number'
            pattern: 'inherited'
          }
        }
        settings {
          color_palette: 'Five-Plus-One'
        }
      }

It still throws an error saying that String values arenā€™t allowed. I noticed the property also accepts a number. I tried using numbers between 1 and 8 (number of palettes I have), but they all ended up showing the default palette.

Hi @shahidt,

I apologize for the delayed response. I overlooked your message earlier.

Could you please open the edit UI and select Five-Plus-One in the UI? Iā€™ve noticed that the color palette name in the code differs from the label in the Color Palette UI.

After doing that, you can remove all the color mapping settings in the code, as illustrated in my previous reply: Holistics Community Post.

@Tai_Nguyen I got around to trying the proposed solution, and the interface left me with a numeric value for the palette. It also worked as expected. Thanks.

1 Like

@Tai_Nguyen this feature is still very buggy. When I navigate to a different report and come back to the page that has the custom palette, it shows the default palette colours. Then if I click on the cache reset button, it shows the right colours.

1 Like

Hi @shahidt, thank you for updating/reporting your issue with us. Our engineering team is checking this issue. I will let you know if thereā€™s any update on this issue.

hi @shahidt , Holistics just released a patch to fix your issue. I believe your issue was already solved. Could you help check on your side?

@Tai_Nguyen Unfortunately, it is still buggy. The earlier bug of not using the custom palette is fixed and every time I visit the dashboard, it uses my custom palette. However, the colour assignment is now incorrect.

It actually used to work well before the latest changes. In my custom palette, I have defined five shades of green and then one orange. The expectation is to use the five shades of green for each of the pie slices, where I am showing Top 5 labels and a sixth slice for ā€˜Othersā€™.

When I first chose the custom palette in the Edit view, it used to assign the six colours to all the possible dimension values, and not just the Top Five plus Others. However, after saving and when it only showed the Top five label, it used to properly assign five shades of green to the Top 5 labels and then the orange to Other.

Based on the picture below, it seems to first assign colour to all labels and then chose the Top 5 from there. Ideally it should first choose the top five dimensions and then just assign colours.

@Tai_Nguyen please see the attached image for palette definition and expectation. Earlier, the ā€˜How it should workā€™ part was what I got, but after the latest changes, I donā€™t get that anymore.

@Tai_Nguyen I just noticed that the feature where any paletteā€™s sequentially defined colours were being used on the slicers that were visible after any filters are now not working, even in legacy dashboards and default palettes.

Hi @shahidt, apologies for the delayed response!

Weā€™re currently rechecking the issue and will keep you updated on our progress.

Hi @shahidt,

After investigating, weā€™ve confirmed this is a valid issue and are working on a fix. It looks like we overlooked the ā€œGroup small values of Legend into ā€˜Otherā€™ā€ option when handling color assignments.

Thanks so much for reporting it ā€” weā€™ll keep you informed on the progress!

1 Like