dosubot[bot] commented on issue #40708: URL: https://github.com/apache/superset/issues/40708#issuecomment-4613277866
<!-- Answer --> You're right, apologies for the confusion — PR #39297 addresses color *collisions* (two series getting the same color), not the issue you're describing where `label_colors` are completely ignored on initial render. After a deeper look, your issue is a **distinct race condition** in the dashboard initialization pipeline. Here's what's happening: **The race condition:** The dashboard's color initialization fires asynchronously via `applyDashboardLabelsColorOnLoad()` [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/actions/dashboardState.js#L814-L887), which populates `forcedItems` in `CategoricalColorNamespace` through a multi-phase `applyColors()` process [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/utils/colorScheme.ts#L205-L281). Meanwhile, charts begin rendering **in parallel** — they don't wait for forced colors to be set. If a chart queries `getColor()` before the async initialization completes, it falls through the priority hierarchy past forced colors (which are empty) and lands on the default color scheme [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts#L122-L169). **Why it's intermittent:** - The dashboard component mounts and triggers both color initialization and chart data fetching concurrently [[4]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx#L232-L247) - Some charts fetch/render faster than others — those that finish before `applyColors()` populates `forcedItems` get default colors - Additionally, there are hardcoded 500ms debounce delays in the sync functions [[5]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/actions/dashboardState.js#L927) that create timing assumptions **Why interaction fixes it:** After any user interaction, `updateDashboardLabelsColor()` re-synchronizes colors, and by that point `forcedItems` is fully populated, so charts get the correct `label_colors` [[6]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx#L201-L230). **Current state:** I couldn't find an existing open issue or PR that specifically addresses this initial-render timing bug. The mitigation attempts in the code (a `dashboardLabelsColorInitiated` state flag and post-render sync) don't fully prevent the first-render mismatch when chart rendering outpaces async color initialization [[7]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx#L206-L209). This appears to be an unaddressed gap in the current rendering pipeline. A potential fix would involve blocking chart rendering until `applyDashboardLabelsColorOnLoad()` completes, or making the color application synchronous before charts begin their render cycle. This could be worth flagging for maintainer attention as a new bug distinct from the collision issues addressed in recent PRs. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=4c5ad9d3-b0f0-4629-9723-f8a39e2a0d38) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset) -- 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]
