Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there any ways to set the color for the chart specifically #2524

Closed
ijyun opened this issue Mar 30, 2017 · 23 comments
Closed

Are there any ways to set the color for the chart specifically #2524

ijyun opened this issue Mar 30, 2017 · 23 comments

Comments

@ijyun
Copy link

ijyun commented Mar 30, 2017

Hi team,
Right now,When I refresh the dashboard the color of the chart would change automatically.I want to set the color for the chart and dont' change after refresh.
Could you please tell me are there any ways?
Thanks

@alanmcruickshank
Copy link
Contributor

@ijyun - not at the moment. Could be an interesting feature to implement. I know several people have enquired about it.

@mistercrunch
Copy link
Member

It's somewhat challenging. Currently we guarantee that metrics of the same name in a dashboard will be the same color across charts.

There's this function/object that cycles through the palette and provide a new color for new expressions and memoizes as it goes. If you ask for Metric 1 twice it'll give you the same color.

Early on I would hash "Metric 1" and provide a color based on the hash so that "Metric 1" would ALWAYS be the same color. The problem there was that with say 8 colors, you relatively often get in situation where a chart with say 2 or 3 metrics will get the same color twice, and that's no good. A chart with "Metric 1" and "Metric 2" might have the same color for both 1 out of 8 times...

Someone in the community said they pre-populate that memoized object with an array of all their important metrics.

For reference:
https://github.com/airbnb/superset/blob/master/superset/assets/javascripts/modules/colors.js#L51

Somehow f you call category21 for an array of metrics, before you render the dashboard, colors for these metrics will be deterministic.

@olegIn80
Copy link

Hi mistercrunch
we are interesting in this feature, can you give an advise to understand better the mechanism how is working now and how we can implement this feature .

Thanks

@mistercrunch
Copy link
Member

It'd be nice to support different color schemes, and allow people to pick a default in their environment. It would also be nice to make "Colors" one of the core set of controls, cohesive across visualizations, but that's a bit more complicated.

For now the categorical colors are defined here:
https://github.com/apache/incubator-superset/blob/master/superset/assets/javascripts/modules/colors.js#L6

A first step might be to define an object with different color sets, and add a new control to most visualizations that would allow to pick the color set. And add a new DEFAULT_COLOR_SET variable in superset/config.py.

@renanoliveira
Copy link

Hello guys!
Do you have any update about that?

In my company different products use different colors but same superset, in my particular case I can not use unique color pallet.

@mistercrunch
Copy link
Member

It's somewhat easy to add new palettes and set one as default but you'll have to do this in your fork.
https://github.com/apache/incubator-superset/blob/master/superset/assets/javascripts/modules/colors.js#L130

It could be nice to add an environment variable to define your default color scheme without having to alter the code and bake your own build.

@shinabarger
Copy link

Agreed, this would be a great feature to have. To be able to change colors for any chart customized for each breakdown of the Group By feature.

For example, have a pie chart with 2 different categories and custom pick which colors those categories show up in the pie chart. See below image as an example.
2018-06-07_9-41-35

@mistercrunch
Copy link
Member

There's now a way to do this that should work in most cases:
http://superset.apache.org/faq.html#is-there-a-way-to-force-the-use-specific-colors

@mistercrunch
Copy link
Member

There's now a way to do this that should work in most cases:
http://superset.apache.org/faq.html#is-there-a-way-to-force-the-use-specific-colors

@frischknechtna
Copy link

frischknechtna commented Jun 22, 2018

@mistercrunch I tried to enforce a colors in the link described way but wasn't really successful. Have you experience in defining colors in superset and maybe a more precise experience?

@dominijk
Copy link

@mistercrunch I've also tried that method as SO question without success.

@mistercrunch
Copy link
Member

screen shot 2019-01-31 at 9 50 16 pm

screen shot 2019-01-31 at 9 49 33 pm

{"filter_immune_slices": [], "timed_refresh_immune_slices": [], "filter_immune_slice_fields": {}, "expanded_slices": {}, "default_filters": "{}",
"label_colors": {
        "Girls": "#FF69B4",
        "Boys": "#ADD8E6"
    }
}

@dominijk
Copy link

dominijk commented Feb 1, 2019

I got that to work but for me the chart must also be set to the default colour scheme

@mistercrunch
Copy link
Member

Wait do you want to set colors a specific way or do you want the default color scheme?

@dominijk
Copy link

dominijk commented Feb 1, 2019

Specific colours for keys but these persist across an entire instance of superset. Per dashboard is fine but I will test as a scheme if that can be key specific?

With the dashboard code it will only alter the chart if the chart is using the default colour scheme (for me) if you select a different colour scheme the override does not work.

@mistercrunch
Copy link
Member

I'd be nice to add a global environment setting for this, I'm not sure why this only applies to the default color scheme, but that's not the intended behavior.

@mlberg
Copy link

mlberg commented Feb 10, 2019

I can confirm you have to have this set to the default color scheme to work.

@rangerscience
Copy link

@mistercrunch How do I get to the "JSON Metadata" view from your top screenshot?

@danmdoherty
Copy link

@rangerscience viewing the dashboard, click "Edit Dashboard", then click the ▼ menu and select "edit dashboard metadata".

Screen Shot 2019-04-01 at 10 56 17 AM

@mohan770
Copy link

mohan770 commented Apr 2, 2020

HI @mistercrunch I have tried ur method but it is showing an error has occurred I have given exactly without any error can u give some more info regarding this

@garyganyang
Copy link

How to change x,y axis label color? anyone know about this? many many thanks

@EBoisseauSierra
Copy link
Contributor

@hosswald
Copy link

This is still broken in 1.2.0.
I found, strangely, that

  "label_colors": {
    "SUCCESS": "#2ca02c",
    "WARNING": "#ff7f0e",
    "ERROR": "#d62728"
  },
  "color_scheme": "SUPERSET_DEFAULT"

works, while

  "color_scheme": "SUPERSET_DEFAULT",
  "label_colors": {
    "SUCCESS": "#2ca02c",
    "WARNING": "#ff7f0e",
    "ERROR": "#d62728"
  }

does not, e.g. JSON metadata order matters (which does not make any sense).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests