Skip to content

fix(mcp): put metrics first in pie and treemap captions - #46127

Draft
aminghadersohi wants to merge 1 commit into
masterfrom
fix-pie-chart-caption-metric-order-2
Draft

aminghadersohi wants to merge 1 commit into
masterfrom
fix-pie-chart-caption-metric-order-2

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Put metrics before dimensions in MCP-generated pie/donut captions and default saved-chart names (total_revenue by region). The sibling treemap builder had the same reversal and uses the same convention.

Preserve metric-label precedence, filter context, explicit titles, and existing saved names. No stored chart names are migrated.

Siblings checked:

  • superset/mcp_service/chart/chart_utils.py: _pie_chart_what and _treemap_chart_what changed; _xy_chart_what and _gauge_chart_what already use metric-first ordering. Table, bubble, pivot table, mixed timeseries, handlebars, and big number builders use summary/comparison formats, not reversed metric-by-dimension text.
  • superset/mcp_service/chart/plugins/pie.py: sole caller of _pie_chart_what; delegates through generate_chart_name.
  • superset/mcp_service/chart/plugins/: sunburst, waterfall, and box plot already put metrics first; other name builders use non-comparable formats.
  • superset/mcp_service/chart/tool/generate_chart.py: default name flows into CreateChartCommand.slice_name and accessibility alt_text; covered by saved pie/donut regression tests.
  • superset/mcp_service/chart/tool/update_chart.py and update_chart_preview.py: shared default-name consumers inherit the change; explicit/existing titles retain precedence.
  • tests/unit_tests/mcp_service/chart/test_new_chart_types.py: updated both assertions pinning reversed pie names; added pie/donut metric-label/filter and treemap regressions. Repository search found no other _pie_chart_what callers or literal old-caption expectations. Chart plugin inventory tests do not pin this text.

Searches: rg -n 'def .*what|return f.* by ' superset/mcp_service/chart/chart_utils.py, rg -n '_pie_chart_what|product by revenue|product by Total Revenue|region by total_revenue' ., and plugin generate_name/tool generate_chart_name searches.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Text-only behavior:

  • Before: Chart showing region by total_revenue; default saved name region by total_revenue.
  • After: Chart showing total_revenue by region; default saved name total_revenue by region.

TESTING INSTRUCTIONS

  • Regression selection on unchanged master source: 11 failed (expected ordering mismatches).
  • PYTHONPATH=$PWD/superset-core/src:$PWD pytest -q tests/unit_tests/mcp_service/chart -m 'not manual and not llm_compliance': 6805 passed, 3 skipped in 277.69s.
  • git add <four touched files> && pre-commit run: all applicable hooks passed (including mypy, Ruff, and pylint); rerun after Ruff formatting.
  • No real-LLM checks run; manual/llm_compliance tests deselected.
  • Generate a pie or donut with dimension region, saved metric total_revenue, and no explicit title; check the caption and default saved name. Explicit titles should remain unchanged.

ADDITIONAL INFORMATION

  • No migration or feature flag changes.
  • Existing saved names are not renamed; shell frontend/submodule changes are outside this PR.
  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process: [SIP-59] Proposal for Database migration standards #13351 )
    • 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

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Nov 10, 2026
@netlify

netlify Bot commented Nov 10, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 268e7cf
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6af2acf17680e8aac99735d1
😎 Deploy Preview https://deploy-preview-46127--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.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.36%. Comparing base (a131fcb) to head (268e7cf).

Files with missing lines Patch % Lines
superset/mcp_service/chart/chart_utils.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #46127   +/-   ##
=======================================
  Coverage   65.35%   65.36%           
=======================================
  Files        3083     3083           
  Lines      211224   211224           
  Branches    49803    49803           
=======================================
+ Hits       138054   138057    +3     
+ Misses      69992    69990    -2     
+ Partials     3178     3177    -1     
Flag Coverage Δ
hive 34.05% <0.00%> (ø)
mysql 51.81% <0.00%> (ø)
postgres 51.84% <0.00%> (+<0.01%) ⬆️
presto 35.69% <0.00%> (ø)
python 52.13% <0.00%> (+<0.01%) ⬆️
sqlite 51.52% <0.00%> (ø)

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.

This branch has not been deployed

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

Labels

doc Namespace | Anything related to documentation size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant