superset icon indicating copy to clipboard operation
superset copied to clipboard

fix(treemap): restore sequential coloring + remove label box, 1px gap (fixes #36807)

Open hassaansaleem28 opened this issue 11 months ago • 6 comments

User description

SUMMARY

  • Restore sequential (continuous) coloring for Treemap when a numeric metric with varying values is present, while preserving categorical coloring for categorical/constant metrics.

  • Remove boxed label appearance and eliminate the 1px gap by default.

  • Ensure de-emphasized (filtered-out) nodes are muted via opacity rather than overriding their color so gradients remain visible.

  • Add unit tests to prevent regressions.

BEFORE/AFTER SCREENSHOTS

-- BEFORE : image

-- AFTER : image

Screenshot 2025-12-27 204635

TESTING INSTRUCTIONS / FILES MODIFIED

  • transformProps.ts — core logic and label/de-emphasis changes
  • constants.ts — adjusted defaults for BORDER_WIDTH / GAP_WIDTH to remove thin gap
  • transformProps.test.ts — new/updated tests

What I Changed

  • Behavior: Treemap now:

    • Automatically uses a sequential palette via the sequential scheme registry when metric values vary (min !== max).
    • Falls back to categorical palette behavior otherwise.
    • Uses opacity for de-emphasis instead of forcing a text color.
  • UI: Labels no longer display a visible border/background by default, and that 1px gap.

  • Typing: Replaced @ts-ignore with a typed assignment for visualMap.

  • Tests: Added Jest tests validating visualMap existence for numeric-varying metric and absence for constant metrics.

Fixes


CodeAnt-AI Description

Restore continuous coloring for numeric treemaps and remove boxed labels

What Changed

  • Treemap now shows a continuous/sequential color gradient when the metric column has varying numeric values; static/categorical metrics keep categorical colors.
  • The visible label box and the thin 1px gap around labels are removed by default so labels render without a border or background.
  • Filtered/de-emphasized nodes are muted using opacity so their color gradients remain visible instead of being overridden.
  • Adds unit tests that verify sequential coloring is applied only for varying numeric metrics.

Impact

✅ Clearer sequential color gradients for numeric treemaps ✅ No boxed labels or thin gaps around treemap labels ✅ Filtered nodes retain underlying color gradients (better visual fidelity)

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

hassaansaleem28 avatar Dec 27 '25 17:12 hassaansaleem28

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X · Reddit · LinkedIn

Code Review Agent Run #d0ad56

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts - 1
    • Type safety violation · Line 325-325
      The code uses `as any` for accessing `linearColorScheme` from `formData` and assigning `visualMap` to `echartOptions`, violating the project's rule against using `any` types for proper TypeScript safety. This affects type checking and maintainability. Consider updating the types to include `linearColorScheme` in `EchartsTreemapFormData` and ensuring the ECharts option type supports `visualMap` without casting.
  • superset-frontend/plugins/plugin-chart-echarts/test/Treemap/transformProps.test.ts - 1
    • TypeScript Standards Violation · Line 78-106
      The added test cases use `as any` and `@ts-ignore` which violate the project's TypeScript standards requiring proper typing without `any` or ignore directives. Since `EChartsCoreOption` doesn't include `visualMap` in its type definition, casting `echartOptions` to `any` for access is acceptable here, but remove the unnecessary `as any` on `formData` and replace `@ts-ignore` with the cast to maintain consistency with the implementation code.
Review Details
  • Files reviewed - 3 · Commit Range: 5c34a05..47a16af
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/constants.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Treemap/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Dec 27 '25 17:12 bito-code-review[bot]

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • [ ] Numeric parsing edge case
    The metric value parsing uses Number(v) for non-number inputs; this converts empty strings to 0 which can incorrectly inflate metricMin/Max and cause useSequential to be true/false incorrectly. Ensure null/empty strings and non-numeric values are excluded rather than coerced to 0.

  • [ ] Label de-emphasis
    De-emphasis applies an opacity to the node's itemStyle but the label is left unchanged (labelProps has no opacity). Labels may remain fully opaque and visually prominent even when the node rectangle is muted. Verify labels inherit or are explicitly muted so de-emphasis visually reduces both fill and text.

  • [ ] Accessibility / contrast
    Removing the label box/background can reduce text contrast on varied node colors. Ensure contrast/accessibility is preserved (e.g., test on dark/light node colors) or ensure consumers apply appropriate text shadows/contrast-aware styles.

  • [ ] visualMap configuration
    visualMap is assigned dynamically but lacks an explicit 'type' (continuous) and may rely on defaults. Also the fallback colors are built from categorical colorFn('min'/'max') which could mismatch true sequential palettes. Verify visualMap.type and color selection logic to ensure correct continuous mapping and consistent color intent.

  • [ ] Visual regression risk
    Changing the default BORDER_WIDTH and GAP_WIDTH from 2 to 0 will remove the thin gap and label box, but may cause label overlap or reduced readability on certain datasets/backgrounds. Validate across multiple datasets, sizes, DPI/zoom levels and with long labels to ensure no overlap or truncation/regression is introduced.

CodeAnt AI finished reviewing your PR.

Code Review Agent Run #1e540b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 47a16af..91696e4
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/constants.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Treemap/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Dec 27 '25 18:12 bito-code-review[bot]

Hello maintainers @rusackas @msyavuz @geido @kgabryje, Just checking in on this PR. Please let me know if any changes, tests, or adjustments are needed. I'd be happy to update it. Thanks for your time!

hassaansaleem28 avatar Dec 31 '25 17:12 hassaansaleem28

Deploy Preview for superset-docs-preview ready!

Name Link
Latest commit bf3cf81f93243efc3dad2b1db991f9340879a56c
Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6981353804b749000839ec62
Deploy Preview https://deploy-preview-36847--superset-docs-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify avatar Feb 02 '26 23:02 netlify

Code Review Agent Run #7f1f44

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 91696e4..bf3cf81
    • superset-frontend/packages/superset-ui-switchboard/src/switchboard.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/constants.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Treemap/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Feb 03 '26 00:02 bito-code-review[bot]

Aww dang... why did you close this @hassaansaleem28 ?

That little one pixel line has been bothering me forever... I just never got around to investigating it.

rusackas avatar Feb 09 '26 07:02 rusackas