GitHub user dosubot[bot] added a comment to the discussion: How to set custom 
colors and specific category order in Bar Chart (Superset 4.1.1)?

<!-- Answer -->
Directly setting custom colors and a fixed category order for ECharts Bar 
Charts in Superset 4.1.1 isn’t fully supported through the UI. The “Color 
Scheme” option lets you pick a palette, but not assign specific colors to 
specific values. Similarly, category order is controlled by sorting options 
(like alphabetical or by value), but not by a manual list.

If you have admin access and can edit config files, you can define a custom 
color scheme in your `EXTRA_CATEGORICAL_COLOR_SCHEMES` in `superset/config.py` 
to match your desired colors. However, this will only set the color sequence, 
not map colors to specific values. For per-value color mapping, Superset’s 
codebase uses the `CategoricalColorNamespace.setColor()` method, but this isn’t 
exposed in the UI—using it would require a code change or a custom plugin. More 
details on this approach are in the [source 
code](https://github.com/apache/superset/blob/93583220a7aa4debeaf3fd4a6cade9f771ee8c2f/superset-frontend/packages/superset-ui-core/src/color/CategoricalColorNamespace.ts)
 and [config 
example](https://github.com/apache/superset/blob/93583220a7aa4debeaf3fd4a6cade9f771ee8c2f/superset/config.py).

For category order, the ECharts Bar Chart plugin supports sorting by value or 
name, but not by a custom list. Workarounds include manipulating your dataset 
or using a CASE statement to prefix values for sorting, but there’s no UI field 
for explicit order. The relevant logic is in the [series sorting 
code](https://github.com/apache/superset/blob/93583220a7aa4debeaf3fd4a6cade9f771ee8c2f/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts).

If you need full control, consider the Plotly plugin for Superset, which lets 
you write Python code for custom charts—including explicit color and order 
mapping. See [this 
discussion](https://github.com/apache/superset/discussions/32756) for details.

For more on customizing chart colors, check out the [Customizing Chart Colors 
with Superset & 
Preset](https://preset.io/blog/customizing-chart-colors-with-superset-and-preset/)
 blog post.

Let me know if you want more details on any of these approaches!


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/cde23659-a05b-4541-b4bb-f4cf0e50ff18?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Sh
 are on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/33836)

GitHub link: 
https://github.com/apache/superset/discussions/36148#discussioncomment-14995348

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to