Skip to content

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

Draft
SBIN2010 wants to merge 78 commits into
apache:masterfrom
SBIN2010:feat/add_butterfly_chart
Draft

feat(plugin-chart-echarts): add Butterfly Chart#43346
SBIN2010 wants to merge 78 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 ee7845d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a862ae1dc1cab000840f81d
😎 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

TimePivot = 'time_pivot',
TimeTable = 'time_table',
Timeseries = 'echarts_timeseries',
Tornado = 'tornado',

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.

CWE-11234: Missing Chart Plugin Implementation

The Tornado enum entry references 'tornado' but no Tornado chart plugin implementation exists anywhere in the codebase (no plugin in plugin-chart-echarts, no import in MainPreset.ts, and no backend implementation). This creates an unusable enum value — if a user selects 'Tornado' as a visualization, the system has no plugin to handle it. Compare with Butterfly which is fully implemented and registered. Either remove this enum entry or implement the complete Tornado chart plugin first. (See also: CWE-11234)

Code Review Run #ce7ea6


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

...DEFAULT_LEGEND_FORM_DATA,
...DEFAULT_TITLE_FORM_DATA,
showValue: true,
truncateXAxis: true,

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.

Dead default without control

The truncateXAxis: true property at line 29 is dead code. This property is not exposed as a configurable control in controlPanel.tsx and is not consumed in transformProps.ts — only showValue and xAxisLabelRotation are extracted from formData. Comparing against the similar Bubble chart (which uses truncateXAxis in both controlPanel and transformProps), this Butterfly implementation is incomplete and the default cannot be changed by users.

Code Review Run #ce7ea6


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

export const DEFAULT_FORM_DATA = {
...DEFAULT_LEGEND_FORM_DATA,
...DEFAULT_TITLE_FORM_DATA,
showValue: true,

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.

Suggestion: The chart default enables showValue, while the corresponding showValueControl defaults to false. When show_value is absent from new or legacy form data, the transform fallback displays labels even though the control panel presents the option as unchecked, causing the chart and saved configuration defaults to disagree. Use the same default in both places. [logic error]

Severity Level: Major ⚠️
- ⚠️ Butterfly charts with absent `show_value` display unexpected bar labels.
- ⚠️ The Chart Options checkbox reports the opposite default state.
- ⚠️ Saved or partially populated form data can preserve this mismatch.

Use CodeAnt Skill

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/constants.ts
**Line:** 28:28
**Comment:**
	*Logic Error: The chart default enables `showValue`, while the corresponding `showValueControl` defaults to false. When `show_value` is absent from new or legacy form data, the transform fallback displays labels even though the control panel presents the option as unchecked, causing the chart and saved configuration defaults to disagree. Use the same default in both places.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.65%. Comparing base (d114eb6) to head (5ae6206).
⚠️ Report is 68 commits behind head on master.

Files with missing lines Patch % Lines
...ugin-chart-echarts/src/Butterfly/transformProps.ts 71.69% 15 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   66.66%   66.65%   -0.01%     
==========================================
  Files        2873     2879       +6     
  Lines      163654   163735      +81     
  Branches    37771    37791      +20     
==========================================
+ Hits       109093   109141      +48     
- Misses      52432    52465      +33     
  Partials     2129     2129              
Flag Coverage Δ
javascript 73.76% <66.66%> (-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.

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.

2 participants