Repository navigation
feat(plugin-chart-echarts): add Butterfly Chart - #43346
Conversation
This reverts commit 35aaeb6.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review Agent Run #ce7ea6
Actionable Suggestions - 2
-
superset-frontend/packages/superset-ui-core/src/chart/types/VizType.ts - 1
- CWE-11234: Missing Chart Plugin Implementation · Line 64-64
-
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts - 1
- Dead default without control · Line 29-29
Additional Suggestions - 1
-
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/index.ts - 1
-
Missing thumbnail image · Line 49-49The `thumbnail` field uses an empty string `''`, but other comparable chart plugins in this package (e.g., Bullet, Histogram) import and use actual thumbnail images from their `./images/` directories. Adding a proper thumbnail will improve chart identification in the UI gallery.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts - 1
- Inconsistent currency formatting · Line 127-129
Review Details
-
Files reviewed - 13 · Commit Range:
19151d1..ee7845d- superset-frontend/packages/superset-ui-core/src/chart/types/VizType.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/Butterfly.tsx
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/buildQuery.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/controlPanel.tsx
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/index.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/types.ts
- superset-frontend/plugins/plugin-chart-echarts/src/index.ts
- superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/buildQuery.test.ts
- superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/controlPanel.test.ts
- superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/transformProps.test.ts
- superset-frontend/src/visualizations/presets/MainPreset.ts
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✖︎ Failed
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
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #43346 +/- ##
==========================================
- Coverage 78.96% 78.95% -0.01%
==========================================
Files 2878 2884 +6
Lines 165183 165267 +84
Branches 38170 38193 +23
==========================================
+ Hits 130430 130484 +54
- Misses 32301 32331 +30
Partials 2452 2452
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new ECharts-based visualization plugin, “Butterfly Chart”, wiring it into Superset’s frontend viz registry and providing the core query/buildQuery + transformProps + control panel configuration along with unit tests.
Changes:
- Introduces the
EchartsButterflyChartPluginimplementation (query builder, transformProps, control panel, chart component, types/constants). - Registers the new viz type (
butterfly) inVizTypeandMainPreset. - Adds unit tests covering
buildQuery,transformProps, andcontrolPanel.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| superset-frontend/src/visualizations/presets/MainPreset.ts | Registers the Butterfly plugin in the main visualization preset. |
| superset-frontend/packages/superset-ui-core/src/chart/types/VizType.ts | Adds VizType.Butterfly = 'butterfly' for consistent viz keying. |
| superset-frontend/plugins/plugin-chart-echarts/src/index.ts | Exports the new plugin and transformProps entrypoints. |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/index.ts | Defines EchartsButterflyChartPlugin metadata and lazy-loaded chart entry. |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/Butterfly.tsx | Adds the chart render component wrapping the shared Echart component. |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/buildQuery.ts | Implements query construction for 1 dimension + 2 metrics + optional ordering. |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts | Implements ECharts option generation (diverging bars, legend, axes, tooltip). |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/controlPanel.tsx | Adds Explore control panel configuration for the new viz. |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/types.ts | Adds chart/form-data/transform-props typing for the Butterfly plugin. |
| superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts | Defines default form data for the Butterfly chart. |
| superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/buildQuery.test.ts | Unit tests for Butterfly query behavior (metrics, orderby defaults/overrides). |
| superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/transformProps.test.ts | Unit tests for diverging series values, labels/colors, legend/axes, tooltip toggle. |
| superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/controlPanel.test.ts | Unit tests validating exposed controls and standardized-control mapping. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| controlPanel, | ||
| loadChart: () => import('./Butterfly'), | ||
| metadata: new ChartMetadata({ | ||
| credits: ['https://echarts.apache.org'], | ||
| category: t('Comparison'), | ||
| description: t( | ||
| 'A butterfly chart compares two metrics across categories using horizontal bars ' + | ||
| 'that extend left and right from a central axis.', | ||
| ), | ||
| name: t('Butterfly Chart'), | ||
| tags: [ | ||
| t('Categorical'), | ||
| t('Comparison'), | ||
| t('ECharts'), | ||
| t('Multi-Variables'), | ||
| ], | ||
| thumbnail: '', | ||
| }), |
There was a problem hiding this comment.
Agreed, empty string will render broken in the viz picker. @SBIN2010 can you add a real thumbnail.png (and thumbnail-dark.png) under images/ and import it here, same pattern as Waterfall/index.ts?
There was a problem hiding this comment.
Code Review Agent Run #6747c4
Actionable Suggestions - 1
-
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts - 1
- CWE-693: Default changed silently · Line 28-28
Review Details
-
Files reviewed - 5 · Commit Range:
ee7845d..4eb99a3- superset-frontend/packages/superset-ui-core/src/chart/types/VizType.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts
- superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts
- superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/controlPanel.test.ts
- superset-frontend/plugins/plugin-chart-echarts/test/Butterfly/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 an incremental AI Review. -
/review full- 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
rusackas
left a comment
There was a problem hiding this comment.
LGTM. Chased down bito's regression callout on showValue and it's a false alarm, Histogram and Waterfall use the same shared showValueControl (default false) with no override either, so dropping it actually brings Butterfly in line and fixes the mismatch codeant flagged earlier in the same thread. Replied and resolved both.
One small thing if you don't mind: Butterfly/index.ts still has thumbnail: '', other plugins like Waterfall ship a real image for that. Not a blocker, just nice to have before merge.
I’ll add thumbnail in the next PR, as well as cross-filtering and drill-to-detail. |

SUMMARY
A new visualization type, the Butterfly Chart (based on ECharts), has been added.
The butterfly chart compares two metrics across categories: horizontal bars extend to the left and right from a central axis. It is useful for comparing two indicators across the same categories (e.g., men vs. women, planned vs. actual, or two time periods).
What has been added:
EchartsButterflyChartPlugin(viz_type:butterfly) inplugin-chart-echartsRegistration in
MainPresetandVizTypeQuery: one dimension (groupby), two metrics (
left_metric,right_metric), sorting viaorderby(defaulting to sorting by category)Settings: colors and labels for left/right series, legend, axis formatting, value display on bars, category label rotation
Unit tests for
buildQuery,transformProps, andcontrolPanelTechnical details:
The left metric is displayed with negative values, and the right with positive values (both using
Math.abs)BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
run test
npm run test superset-frontend/plugins/plugin-chart-echarts/test/Butterfly
ADDITIONAL INFORMATION