jansule opened a new issue, #33900:
URL: https://github.com/apache/superset/issues/33900
### Bug description
The charts rendered through the cartodiagram plugin might run into color
collisions for cases when the sets of labels differ. This might lead to
confusion and misinterpretation of the data, since two distinct labels might
share the same color and/or a label might be assigned different colors, within
a single cartodiagram.
Given following dataset:
| geom | value | category |
| --- | --- | --- |
|{ "coordinates": [ 10.021094598147045, 51.12881242291189 ], "type": "Point"
} | 1 | far |
|{ "coordinates": [ 10.021094598147045, 51.12881242291189 ], "type": "Point"
} | 1 | faz |
|{ "coordinates": [ 9.573277401918602, 50.77733656456951 ], "type": "Point"
} | 1 | bar |
|{ "coordinates": [ 9.573277401918602, 50.77733656456951 ], "type": "Point"
} | 1 | baz |
The first two items and the last two items share the same location,
respectively, but have different categories on each location.
If we create a pie chart based on this dataset (using `category` as
dimension) and then reference this pie chart in the cartodiagram plugin,
following two charts will be created on a map:

As you can see, the same colors will be applied for both charts, even though
the labels differ completely (`far` and `faz` for the first chart, `bar` and
`baz` for the second chart).
I would expect that each label has a distinct color throughout the charts
contained in the cartodiagram, and that a single color is not used by two
different labels.
### Screenshots/recordings
_No response_
### Superset version
5.0.0
### Python version
3.9
### Node version
16
### Browser
Not applicable
### Additional context
In our superset fork, I already created a fix on dashboard level (see
https://github.com/terrestris/superset/pull/23). Here, I can manually register
all labels in the `LabelsColorMapSingleton` before creating the single charts.
The result looks as follows:

However, the provided approach only works in the context of dashboards - it
does not work in the explore view, and thus it does not work when embedding a
single chart directly. There, the `LabelsColorMapSingleton` is not being used
but instead a label map for each distinct chart will be created.
In order to solve this problem, we probably have to adjust the approach on
how colors will be assigned during chart rendering.
@villebro Before doing any changes here, it would be great to get some
feedback regarding a feasible approach for that, as otherwise I might oversee
some cases.
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [ ] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]