Skip to content

fix: use Math.max for pyramid chart right-bar palette fallback - #77

Merged
Chenglong-MS merged 5 commits into
microsoft:devfrom
fix2015:fix/pyramid-palette-color-index
Jul 27, 2026
Merged

fix: use Math.max for pyramid chart right-bar palette fallback#77
Chenglong-MS merged 5 commits into
microsoft:devfrom
fix2015:fix/pyramid-palette-color-index

Conversation

@fix2015

@fix2015 fix2015 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Fixed incorrect palette color selection for the pyramid chart's right bar when the palette has 3 colors.

Changes

packages/flint-js/src/echarts/instantiate-spec.ts (line 1101)

Math.min(1, pal.length - 1)Math.max(0, pal.length - 1)

When the palette has fewer than 4 colors, the fallback should select the last color. Math.min caps the index at 1, so a 3-color palette always picks pal[1] (the second color) instead of pal[2] (the last color):

Palette size Math.min(1, len-1) (before) Math.max(0, len-1) (after)
3 colors pal[1] (wrong) pal[2] (last — correct)
2 colors pal[1] (last — ok) pal[1] (last — ok)
1 color pal[0] (only — ok) pal[0] (only — ok)

Test plan

  • Verified the fix selects the correct palette color for all palette sizes
  • No change in behavior for palettes with 4+ colors (the pal[3] branch handles those)

Chenglong-MS and others added 5 commits July 13, 2026 14:39
@Chenglong-MS
Chenglong-MS changed the base branch from main to dev July 27, 2026 20:09
@Chenglong-MS

Copy link
Copy Markdown
Contributor

Very cool observation! This seems to be a special consideration for echarts?

For example, discrete schema

@Chenglong-MS
Chenglong-MS merged commit 7eec229 into microsoft:dev Jul 27, 2026
1 check passed
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