-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[charts-pro] Add onBeforeExport
callback
#18722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[charts-pro] Add onBeforeExport
callback
#18722
Conversation
Deploy preview: https://deploy-preview-18722--material-ui-x.netlify.app/ Updated pages: Bundle size reportTotal Size Change: 🔺+520B(0.00%) - Total Gzip Change: 🔺+248B(+0.01%) Show details for 100 more bundles (22 more not shown)@mui/x-charts-pro parsed: 🔺+52B(+0.01%) gzip: 🔺+22B(+0.02%) |
CodSpeed Performance ReportMerging #18722 will degrade performances by 82.31%Comparing Summary
Benchmarks breakdown
|
* removing elements, etc. | ||
* @param {HTMLIFrameElement} iframe containing the chart to be exported. | ||
*/ | ||
onBeforeExport?: (iframe: HTMLIFrameElement) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should also accept async functions.
onBeforeExport?: (iframe: HTMLIFrameElement) => void; | |
onBeforeExport?: (iframe: HTMLIFrameElement) => Promise<void> | void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 👍
3c4769e
to
1a83847
Compare
docs/data/charts/export/export.md
Outdated
@@ -80,6 +80,18 @@ Additionally, the name of the exported file has been customized to resemble the | |||
If the browser does not support a requested image format, the export defaults to PNG. | |||
::: | |||
|
|||
### `onBeforeExport` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/data/charts/export/export.md
Outdated
When exporting, the chart is rendered onto an iframe and then exported as an image or PDF. | ||
|
||
You can modify the iframe before the export process starts by using the `onBeforeExport` callback. | ||
|
||
This can be useful to add custom styles or modify the chart's appearance before exporting. | ||
|
||
For example, you can hide the toolbar when exporting the chart, as shown below: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A proposal to focus first on what the reader might be looking for before the technical explainination
When exporting, the chart is rendered onto an iframe and then exported as an image or PDF. | |
You can modify the iframe before the export process starts by using the `onBeforeExport` callback. | |
This can be useful to add custom styles or modify the chart's appearance before exporting. | |
For example, you can hide the toolbar when exporting the chart, as shown below: | |
To add custom styles or modify the chart's appearance before exporting, use the `onBeforeExport` callback. | |
When exporting, the chart is rendered onto an iframe and then exported as an image or PDF. | |
The `onBeforeExport` callback gives you access to the iframe before the export process starts. | |
For example, you can hide the toolbar when exporting the chart, as shown below: |
Related to https://github.com/mui/mui-x/pull/17447/files#r2180308840.
Add
onBeforeExport
callback that is called with the iframe used to export the chart.This is useful when users want to fully customize what will be exported.