Conversation
Exposes getDataAsExcel and exportAsExcel on top of the internal data layer. Not registered on any chart yet.
Adds it to the default Premium plugins and to the Bar, Scatter, Heatmap, Candlestick, RadialLine, RadialBar, radial and geo data provider lists. Bar and Scatter now own their lists instead of aliasing Pro's. HeatmapPremium never used its own list: Pro's useHeatmapProps hardcodes the Pro plugins and types apiRef against them, so both are overridden. ChartPremiumApi gains keys for scatter, heatmap, ohlc, radialLine and radialBar, and composition now maps to the Premium defaults.
Covers getDataAsExcel on each Premium chart that registers the plugin and on a composition, option pass-through, the empty chart, and the download name for exportAsExcel.
The declaration build could not name the inferred type of the plugin override (TS4058 on CommonExperimentalFeatures).
DEFAULT_CHART_EXCEL_OPTIONS was the only runtime value exported from a .types.ts file across the charts packages. It now lives in defaults.ts, like the Pro export plugin's defaults.
ChartsToolbarPro gains a generic exportMenuItems render prop, so the Premium toolbar can append to the export menu without duplicating it. ChartsToolbarPremium wraps it with ChartsToolbarExcelExportTrigger, and becomes the default toolbar of the Premium charts that register the export plugin. The trigger takes an onExport override, which the Data Grid integration will use. Adds the toolbarExportExcel locale key, the docs section and its demo.
Deploy previewBundle size
PerformanceTotal duration: 1,663.74 ms -167.15 ms(-9.1%) | Renders: 63 (+0) | Paint: 2,282.25 ms -242.58 ms(-9.6%)
…and 9 more (+12 within noise) — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #14246. Stacked on #23597, which adds the export plugin, so this branch contains that PR's commits too. Review only the last commit, or wait until #23597 merges and this diff shrinks to its own change.
This PR
Puts the Excel export in the toolbar, so it is reachable without
apiRef.The export menu gains a Download as Excel entry next to Print and the image formats.
{{ demo in
docs/data/charts/export/ExportChartAsExcel.tsx}}Customize it, or remove the entry, through the toolbar slot:
How it is wired
ChartsToolbarProgains a genericexportMenuItemsrender prop, about four lines, called with{ onClose }at the end of the export menu. No Premium concept entersx-charts-pro, and the alternative was duplicating a 250-line toolbar into Premium.ChartsToolbarPremiumwraps the Pro toolbar and passes that render prop. It is now the default toolbar of the four Premium charts that own their plugin list:BarChartPremium,ScatterChartPremium,HeatmapPremiumandCandlestickChart. The radial charts have no default toolbar today, so they are left alone.ChartsToolbarExcelExportTriggerfollowsChartsToolbarImageExportTrigger, with one addition: an optionalonExportprop overridingapiRef.current.exportAsExcel. The Data Grid integration needs that, since the chart there is rendered by the Pro components.Localization: one new key,
toolbarExportExcel, defaulting toDownload as Excel, matching the Data Grid's string.pnpm l10nadds the usual commented placeholder to the partial locales.Tests
Three tests render
BarChartPremiumwithshowToolbar, open the export menu, and check the entry is listed, that clicking it downloads an.xlsxwith the configured name, and thatdisableToolbarButtonhides it.Full suites pass for
x-charts(648),x-charts-pro(228) andx-charts-premium(159), along with typecheck, eslint, prettier and vale.Generated with
pnpm proptypes,pnpm docs:api,pnpm docs:typescript:formattedandpnpm l10n.