-
Notifications
You must be signed in to change notification settings - Fork 16.6k
feat: add custom thresholds and colors to CountryMap plugin #36732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add custom thresholds and colors to CountryMap plugin #36732
Conversation
|
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 · |
Nitpicks 🔍
|
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/transformProps.js
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/transformProps.js
Outdated
Show resolved
Hide resolved
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review Agent Run #d66de9
Actionable Suggestions - 2
-
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js - 2
- Prop name mismatch in PropTypes · Line 44-44
- Incorrect Color Scale Implementation · Line 159-169
Additional Suggestions - 3
-
superset-frontend/plugins/legacy-plugin-chart-country-map/src/transformProps.js - 1
-
Convert JS to TS for type safety · Line 27-27This JavaScript file should be converted to TypeScript to align with codebase standards that prohibit new JavaScript files and require type safety. The added customColorScale parsing logic is correct but would benefit from TypeScript types for better maintainability.
-
-
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js - 2
-
Outdated CSS color regexes · Line 57-60The regexes for CSS color functions only match comma-separated syntax (e.g., rgb(255, 0, 0)), but modern CSS supports space-separated syntax (e.g., rgb(255 0 0)). This could cause valid modern color strings to be rejected as invalid, falling back to '#000000'.
-
Unused function (dead code) · Line 78-89The rgbaToHex function is defined but never called in the codebase. While it might be intended for future color handling, removing it now keeps the code clean and avoids maintenance overhead.
-
Review Details
-
Files reviewed - 3 · Commit Range:
ca2e1b8..30fcc46- superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
- superset-frontend/plugins/legacy-plugin-chart-country-map/src/controlPanel.ts
- superset-frontend/plugins/legacy-plugin-chart-country-map/src/transformProps.js
-
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 Default Agent You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Show resolved
Hide resolved
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Code Review Agent Run #3475b2Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Hi, |
|
Running CI! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds customizable color scales to the CountryMap plugin, allowing users to define custom color thresholds based on percentage values. The feature enables more flexible thematic map visualizations by letting users override the default linear color scheme with JSON-configured breakpoints and colors.
Key Changes:
- Added JSON-based custom color scale configuration that accepts percent/color pairs for precise threshold control
- Introduced a color picker control to help users select and identify HEX color codes
- Implemented robust error handling for invalid JSON, malformed color values, and edge cases in metric data
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
transformProps.js |
Parses and validates the custom color scale JSON configuration, passing sanitized data to the chart component |
controlPanel.ts |
Adds two new controls: a TextArea for JSON color scale input and a ColorPicker for color selection assistance |
CountryMap.js |
Implements core logic for custom color scale processing, including color validation, data normalization, and fallback handling for both custom and linear color schemes |
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/controlPanel.ts
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/controlPanel.ts
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
Show resolved
Hide resolved
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Hi,
|
Code Review Agent Run #89823cActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…CountryMap.js Co-authored-by: Copilot <[email protected]>
…CountryMap.js Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…CountryMap.js Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…transformProps.js Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
|
Hi @rusackas and dear reviewers/mainteainers I'm struggling to keep this PR in sync with master branch and handling AI bot comments that are pretty relevant, but tend to introduce more complexity than it should. Goal here is not to provide a fancy UI or too much guidance for end-users, but to give more control on chloropleth map rendering for advanced map creators. I hope these latest changes might help making advance into integrating this into the project :) Yours |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review Agent Run #32187a
Actionable Suggestions - 1
-
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js - 1
- Broken interpolator function · Line 163-165
Review Details
-
Files reviewed - 3 · Commit Range:
63c7506..3e81051- superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
- superset-frontend/plugins/legacy-plugin-chart-country-map/src/controlPanel.ts
- superset-frontend/plugins/legacy-plugin-chart-country-map/src/transformProps.js
-
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
| .interpolate(function (a, b) { | ||
| return a; | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interpolate method must return an interpolator function, not a value. Returning 'a' directly will cause a TypeError when d3 calls it with a parameter t, breaking color scaling for custom color rules.
Code suggestion
Check the AI-generated fix before applying
| .interpolate(function (a, b) { | |
| return a; | |
| }); | |
| .interpolate(function (a, b) { | |
| return function(t) { return a; }; | |
| }); |
Code Review Run #32187a
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
User description
SUMMARY
Add a JSON-based customization block that allows to override linearColorScheme colors and thresholds with custom thresholds and colors.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Paste a sample customization in "Custom Color Scale": the linearScheme is overrided, resulting in the customized Color Scheme to apply.
[ { "percent": 0, "color": "white" }, { "percent": 0.01, "color": "#FF0000AA" }, { "percent": 20, "color": "#FA0" }, { "percent": 50, "color": "#FF0" }, { "percent": 65, "color": "#9F0" }, { "percent": 99.99, "color": "#000A" }, { "percent": 100, "color": "black" } ]The inline help provides a sample configuration that can also be copied/pasted (with some cleaning and lines returns).
Edit sample values to adjust to the map needs: the changes appear immediately on map
The provided configuration requires a full valid JSON, including brackets, commas except for the last line, quoted keys and quoted values for color codes.
ADDITIONAL INFORMATION
CodeAnt-AI Description
Allow custom percent-based color scales for CountryMap and add a color picker
What Changed
Impact
✅ Clearer thematic maps with user-defined thresholds✅ Immediate visual feedback when editing color scales✅ Fewer rendering errors from invalid custom color inputs💡 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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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.