Skip to content

Color per bar#726

Open
tanugarg04 wants to merge 5 commits intomainfrom
color-per-bar
Open

Color per bar#726
tanugarg04 wants to merge 5 commits intomainfrom
color-per-bar

Conversation

@tanugarg04
Copy link
Contributor

@tanugarg04 tanugarg04 commented Mar 9, 2026

Bar and Legend colorOverrides

Summary

  • Adds colorOverrides to the Bar chart and Legend so specific dimension values (e.g. category labels) can use custom colors while the rest use the chart color scale. Removes the previous colorFromData approach in favor of this override-based API.

Changes

  • Bar
  1. New prop colorOverrides?: Record<string, string> (dimension value → CSS color).
  2. Only applies when color is a field (e.g. color="browser"). Bars that match an override use that color; others use the scale.
  3. Vega: production rules for overrides + scale fallback; fill set in both enter and update when overrides are used.
  4. Scale domain: Color scale domain is only added when options.color is set.
  • Legend
  1. New prop colorOverrides on Legend (same shape as Bar).
  2. When set, legend symbol colors use the same overrides so they match the bars. Color field can come from Legend color or from the color facet when inferred from scales.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@c-lamoureux
Copy link
Contributor

Was it difficult to find a way to use the base colors when specific colors are defined? I think the gray fallback could make it difficult to implement this in our applications.

@github-actions
Copy link

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
71.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

…colorOverrides for consistent color representation
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

Successfully merging this pull request may close these issues.

2 participants