jdgme opened a new issue, #20200:
URL: https://github.com/apache/echarts/issues/20200
### What problem does this feature solve?
I have a use case where I need to add elements (text, banners, etc.) to
charts when they are downloaded, but these additional elements should not be
included in the display of the charts in the browser. I prefer to still have
the ability to utilize toolbox's saveAsImage to trigger this enhanced chart
downloading, especially since taking getDataURL() or getConnectedDataURL() from
the rendered chart in the page does not implement
_saveAsImage.excludeComponents_. Towards this end, I recomment creating a
saveAsImage function parameter (similar to tooltip.formatter) which the
developer can set to further manipulate the saveAsImage prior to it being sent
to the browser for download. "formatter" may not be the best name for this
parameter as it might be misleading for those who think only of formatting
text, but I leave that to the developers/community. Implementation should be
rather straight forward as it just requires passing the current saveAsImage
result to saveAsImage.formatter and
exporting the result of that formatter instead of the current saveAsImage if
the formatter is defined.
Additionally, I recommend/request implementation of #18121 so saveImageAs
can be triggered outside of the echart itself.
### What does the proposed API look like?
## Setting in Options
```
option = {
toolbox: {
feature: {
saveAsImage: {
formatter: function (params) {
return this.myChartFormatFunction(params);
},
},
}
}
};
```
## Documentation
### saveAsImage.formatter
Function
The optional formatter of the saveAsImage output which supports a callback
function.
#### Callback function
```
(params: any) => HTMLCanvasElement
```
The first parameter _params_ is the data that the formatter needs. Its
format is shown as follows:
```
{
// Canvas image generated by saveAsImage
canvas: HTMLCanvasElement,
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]