Skip to content

feat(plugin-chart-echarts): add Butterfly Chart - #43346

Merged
SBIN2010 merged 81 commits into
apache:masterfrom
SBIN2010:feat/add_butterfly_chart
Aug 29, 2026
Merged

SBIN2010 merged 81 commits into
apache:masterfrom
SBIN2010:feat/add_butterfly_chart

Conversation

@SBIN2010

Copy link
Copy Markdown
Contributor

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) in plugin-chart-echarts
Registration in MainPreset and VizType
Query: one dimension (groupby), two metrics (left_metric, right_metric), sorting via orderby (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, and controlPanel

Technical 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

Снимок экрана от 2026-08-20 01-10-33

TESTING INSTRUCTIONS

run test
npm run test superset-frontend/plugins/plugin-chart-echarts/test/Butterfly

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

SBIN2010 and others added 30 commits October 22, 2024 23:07
@dosubot dosubot Bot added the viz:charts:echarts Related to Echarts label Aug 19, 2026
@SBIN2010
SBIN2010 marked this pull request as draft August 19, 2026 22:15
@netlify

netlify Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 2bd7fc8
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a8ca8b160a9e300087b49be
😎 Deploy Preview https://deploy-preview-43346--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/index.ts - 1
    • Missing thumbnail image · Line 49-49
      The `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
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

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.28571% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.95%. Comparing base (ca3d767) to head (4eb99a3).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ugin-chart-echarts/src/Butterfly/transformProps.ts 67.85% 18 Missing ⚠️
...s/plugin-chart-echarts/src/Butterfly/Butterfly.tsx 0.00% 10 Missing ⚠️
...lugin-chart-echarts/src/Butterfly/controlPanel.tsx 75.00% 1 Missing ⚠️
...lugins/plugin-chart-echarts/src/Butterfly/index.ts 66.66% 1 Missing ⚠️
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              
Flag Coverage Δ
javascript 74.32% <64.28%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EchartsButterflyChartPlugin implementation (query builder, transformProps, control panel, chart component, types/constants).
  • Registers the new viz type (butterfly) in VizType and MainPreset.
  • Adds unit tests covering buildQuery, transformProps, and controlPanel.

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.

Comment on lines +33 to +50
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: '',
}),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@SBIN2010
SBIN2010 marked this pull request as ready for review August 24, 2026 22:01

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #6747c4

Actionable Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts - 1
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

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@SBIN2010

Copy link
Copy Markdown
Contributor Author

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.

@SBIN2010
SBIN2010 merged commit 96119ff into apache:master Aug 29, 2026
136 checks passed
@SBIN2010

Copy link
Copy Markdown
Contributor Author
8af83a0ceb8b10f521b128aa2319219f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants