Skip to content

feat(extensions): let an extension draw a chart from form data - #46130

Open
amaannawab923 wants to merge 1 commit into
masterfrom
extensions/charts-namespace
Open

amaannawab923 wants to merge 1 commit into
masterfrom
extensions/charts-namespace

Conversation

@amaannawab923

Copy link
Copy Markdown
Contributor

SUMMARY

An extension that wants to show a chart currently has no way to ask for one. Every piece it would need is a host internal — the Redux store, chartAction's requestChartDataResolved, SuperChart and the plugin registry — and an extension cannot reach any of them: @superset-ui/core is not shared with extensions, and a bundled copy of it is never configured. The choice today is to reimplement querying and drawing, or to not draw charts.

This adds charts.AssetChart, which takes a chart's form data and does both. The host runs the query and hands the result to the plugin the form data names, so what the extension shows is what that chart would be, and the internals stay internal:

import { charts } from '@apache-superset/core';

<charts.AssetChart formData={formData} height={320} />

formData is the same object Explore holds for a chart, so an extension already reading a chart through /api/v1/chart/ has what it needs. The component owns its loading state, surfaces the query's own error message when the query fails, says so plainly when the form data names no viz_type, and contains a plugin that throws while drawing to the chart's own area.

Deliberately narrow. It queries as an unsaved chart: it does not save, does not cache against a saved chart, does not apply a surrounding page's filters, and does not return the rows. It is a chart to look at, not a data API — an extension that wants the numbers already has /api/v1/chart/data.

Ten files, +653 lines, no deletions. New namespace plus its three wiring points (superset-core's export list and package.json subpath, src/core's re-export, and the window.superset binding in Namespaces.ts/ExtensionsStartup.tsx), and a ### Charts section in the contribution-types docs.

Part of making extensions able to carry a feature that shows data. Independent of #45522 — the only overlap is additive lines in the same export lists, so whichever lands second rebases trivially.

TESTING INSTRUCTIONS

superset-frontend/src/core/charts/AssetChart.test.tsx covers the loading state, a successful draw, the query-failure message, the missing-viz_type message, the error boundary around a throwing plugin, and that a stable formData does not re-query.

npm run build --workspace @apache-superset/core
npx jest src/core/charts src/extensions
npm run type

Verified locally: lib/charts builds so the ./charts subpath resolves, tsc --noEmit is clean, 49 tests pass across 6 suites, eslint clean.

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

An extension that wants to show a chart has had no way to ask for one. The
pieces are all host internals -- the Redux store, `chartAction`'s
`requestChartDataResolved`, `SuperChart` and the plugin registry -- and an
extension cannot reach any of them: `@superset-ui/core` is not shared, and a
bundled copy of it is never configured. So the only options were to
reimplement querying and drawing, or to not draw charts.

`charts.AssetChart` takes the form data and does both. The host runs the
query and hands the result to the plugin the form data names, so what the
extension shows is what that chart would be, and the internals stay
internal:

    <charts.AssetChart formData={formData} height={320} />

`formData` is the same object Explore holds, so an extension that already
reads a chart through the API has what it needs. The component owns its
loading state, surfaces the query's own error message, says so plainly when
the form data names no `viz_type`, and contains a plugin that throws while
drawing to the chart's own area.

Deliberately narrow. It queries as an unsaved chart: it does not save, does
not cache against a saved chart, does not apply a surrounding page's
filters, and does not return the rows. A chart to look at, not a data API --
an extension that wants the numbers already has `/api/v1/chart/data`.
@netlify

netlify Bot commented Nov 10, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 30e89ea49f72

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

dependencies:npm doc Namespace | Anything related to documentation packages size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant