swimlane / ngx-charts

:bar_chart: Declarative Charting Framework for Angular
https://swimlane.github.io/ngx-charts/
MIT License
4.3k stars 1.15k forks source link

Export Chart(s) as Image, SVG or base64 string #1773

Closed bvercelli99 closed 2 years ago

bvercelli99 commented 2 years ago

Is your feature request related to a problem? Please describe. This would be a new feature request, no existing issue.

Describe the solution you'd like We were required to export out the charts as an image. I was able to get the SVG(s) from DOM, add my custom styles, write to canvas and export to PNG file. I would be interested in doing a PR for it, but wanted to gauge interest first.

Describe alternatives you've considered An alternative would be not exporting to PNG and so no need for a canvas element, and just allowing to export the SVG/Chart as base64 string for user? That would minimize using any extra elements and allow the user to create png/jpg etc of their choosing.

Additional context Attached is a sample Line Chart Export with some custom styling SampleChartExport

Hypercubed commented 2 years ago

I don't feel this belongs in the charting library. There are a few solutions out there for example: https://www.npmjs.com/package/svgsaver and perhaps some angular wrappers.