Search code examples
cssjsonapache-superset

Where are label_colour keys stored in apache-superset?


Version: Docker instance from here

According to the docs I can edit colours based on labels;

It is possible on a per-dashboard basis by providing a mapping of labels to colors in the JSON Metadata attribute using the label_colors key.

By adjusting the JSON found as below;

enter image description here

enter image description here

Where my code for JSON is;

{
"filter_immune_slices": [],
"timed_refresh_immune_slices": [],
"filter_immune_slice_fields": {},
"expanded_slices": {},
"label_colors": {
"A": "#007F3D",
"B": "#2C9F29",
"C": "#9DCB3C",
"D": "#FFF200",
"E": "#F7AF1D",
"F": "#ED6823",
"G": "#E31D23"
},
"default_filters": "{}"
}

Solution

  • Shortly after offering a bounty I figured out the missing piece of the puzzle..

    The code needed a slight edit as keys needed to be lower case so that became;

    {
    "filter_immune_slices": [],
    "timed_refresh_immune_slices": [],
    "filter_immune_slice_fields": {},
    "expanded_slices": {},
    "label_colors": {
    "a": "#007F3D",
    "b": "#2C9F29",
    "c": "#9DCB3C",
    "d": "#FFF200",
    "e": "#F7AF1D",
    "f": "#ED6823",
    "g": "#E31D23"
    },
    "default_filters": "{}"
    }
    

    However this will still not show the intended colour scheme if you have set the chart colour scheme to anything over than the default option. Set the cahrt colour scheme back to the default and you should get what you want. Default on my build is;

    enter image description here

    To test this go to the example dashboard births and edit dashboard > edit dashboard metadata change the JSON Metadata as below;

    {"filter_immune_slices": [], "timed_refresh_immune_slices": [], 
    "filter_immune_slice_fields": {}, "expanded_slices": {}, "label_colors": 
    {"boy": "#9DCB3C","girl": "#F7AF1D"}, 
    "default_filters": "{}"}