pbcodesC opened a new pull request, #36541:
URL: https://github.com/apache/superset/pull/36541
This pull request introduces a fix for an issue where dashboards containing
multiple charts may assign the same color to different labels within a single
chart. The issue occurs when the dashboard metadata contains an empty or
incomplete map_label_colors, causing Superset to fall back to the automatic
color assignment logic.
During initial dashboard load, charts are rendered in a variable order. When
the first chart assigns colors (e.g., light blue, dark blue, green), subsequent
charts repeat the same indexing-based color selection, resulting in duplicated
colors (e.g., "PC" and "Playstation" both receiving light blue). Refreshing may
change the order of chart rendering, causing inconsistent results.
Root Cause
The function responsible for generating label-color mappings
(getFreshLabelsColorMapEntries) did not account for preventing duplicate color
usage when automatic assignment was required.
It relied solely on the ordering of available colors, without checking
whether a color had already been assigned.
What This PR Changes
This PR introduces logic to ensure that every label receives a unique color
during automatic assignment:
A usedColors Set is added to track colors that have already been assigned.
For each label-color pair:
If the color is already used, the next available unused color is selected
from the active color map.
Otherwise, the existing color is used.
The function now returns an updated color map with guaranteed unique
assignments for each dashboard load.
These changes ensure deterministic and conflict-free color assignment even
when
map_label_colors is missing or incomplete.
What This PR Does Not Modify
This PR intentionally avoids modifying the following:
The persistence mechanism for map_label_colors
Dashboard metadata storage logic
Color theme definitions
The merging logic between stored, custom, and fresh label colors
Backend APIs or database schema
The fix is strictly scoped to frontend color-selection logic to preserve
stability.
How to Reproduce the Bug (Verified)
Import twice-same-color-bug.zip
Ensure map_label_colors is empty via GET /api/v1/dashboard/{pk}
Load the dashboard
Observe that the second chart may assign the same color twice (e.g., light
blue for both “PC” and “Playstation”)
Refresh multiple times to observe inconsistent behavior
This was reproduced and confirmed in Superset 6.0.0rc3 and 5.0.0.
Testing
Verified with the provided sample dashboard
Reloaded multiple times to ensure deterministic results
Confirmed that behavior remains unchanged when custom label colors are
present
Confirmed no regression in existing label color persistence logic
Related Issue
Fixes #36406
Request
If possible, please assign this issue to me.
I am committed to fully completing and maintaining this fix as needed.
--
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]