Skip to content

feat(toolbox): expose toolbox feature extension API - #21709

Open
DaZuiZui wants to merge 1 commit into
apache:masterfrom
DaZuiZui:codex/issue-21693-export-toolbox
Open

feat(toolbox): expose toolbox feature extension API#21709
DaZuiZui wants to merge 1 commit into
apache:masterfrom
DaZuiZui:codex/issue-21693-export-toolbox

Conversation

@DaZuiZui

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Exposes a stable toolbox-feature registration API for independently packaged ECharts extensions.

Fixed issues

Details

Before: What was the problem?

Toolbox features are stored in an internal registry. ECharts extensions installed with echarts.use() cannot access that registry, and the public custom-feature path only recognizes option keys prefixed with my. As a result, an independent package cannot register a first-class feature such as toolbox.feature.exportData without importing internal modules.

After: How does it behave after the fixing?

The extension installer now exposes registerToolboxFeature(name, ctor). ToolboxFeature and its option/model/constructor types, together with the extension installer types, are exported from echarts/core.

An external package can now register a feature through the normal extension lifecycle:

class ExportDataFeature extends ToolboxFeature<ExportDataFeatureOption> {
    onclick(): void {
        // Delegate to the package's shared programmatic exporter.
    }
}

const install: EChartsExtensionInstaller = (registers) => {
    registers.registerToolboxFeature('exportData', ExportDataFeature);
};

echarts.use(install);

The change adds no exporter implementation or third-party dependency to ECharts core. CSV/PDF/XLSX implementations can remain independently packaged and tree-shakeable.

Document Info

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

  • Unit coverage verifies registration through echarts.use().
  • Public DTS coverage verifies subclassing ToolboxFeature and calling registerToolboxFeature from echarts/core.
  • npm run checktype
  • Targeted Jest and ESLint checks
  • DTS tests with TypeScript 4.7 through 5.9

Merging options

  • Please squash the commits into a single one when merging.

Other information

The matching independent exporter prototype uses explicit table / getTable(chart) data sources and shares one exporter registry between its toolbox and programmatic APIs, as described in #21693.

@echarts-bot

echarts-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

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.

1 participant