Skip to content

Export Chart to SVG/PNG #90

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

Closed
LucasNmn opened this issue Jun 23, 2021 · 6 comments · Fixed by #94
Closed

Export Chart to SVG/PNG #90

LucasNmn opened this issue Jun 23, 2021 · 6 comments · Fixed by #94
Labels
Area: MissingAbstraction Plotly.js functionality that has to be implemented

Comments

@LucasNmn
Copy link

Hi,
is there an easy way to export a plotted chart directly from code as PNG or SVG?
I tried it using the ".toChartImage" function from the api but didn't find a working solution yet.

@kMutagene kMutagene added the Area: MissingAbstraction Plotly.js functionality that has to be implemented label Jun 24, 2021
@kMutagene
Copy link
Collaborator

To export charts created with Plotly.NET directly as an image file, you need some kind of headless browser to do the javascript execution to render the chart first. There is a package out there using Pupeteer for that which might work for you, check #21 for that. However, there is an in-house solution by plotly which we still need to wrap for .NET use - It is on the roadmap but not quite here yet.

Related/possible duplicates: #21 and #65.

@LucasNmn
Copy link
Author

Thanks for your advice,
I will test that.

@kMutagene
Copy link
Collaborator

closed via #94. @LucasNmn if you have time and interest you might check out the docs for the new Plotly.NET.ImageExport package here.

@LucasNmn
Copy link
Author

I'm having problems getting the function to work in C#. SaveJPG seems to be unknown while I'm using Preview 6. But I already made my own workaround with Pupperteer as you mentioned in #21 and #65 .

@kMutagene
Copy link
Collaborator

kMutagene commented Jul 12, 2021

Thanks for checking it out, i will test this in C# now to see if there's an issue.

Just to be clear, Plotly.NET.ImageExport is a separate nuget package: https://www.nuget.org/packages/Plotly.NET.ImageExport/. Maybe i should add this to the docs. If you want access to .SaveJP you also have to open the GenericChartExtensions namespace.

But if you have an approach that works for you already, thats just as fine.

@LucasNmn
Copy link
Author

LucasNmn commented Jul 12, 2021

Thanks for checking it out, i will test this in C# now to see if there's an issue.

Just to be clear, Plotly.NET.ImageExport is a separate nuget package: https://www.nuget.org/packages/Plotly.NET.ImageExport/. Maybe i should add this to the docs. If you want access to .SaveJP you also have to open the GenericChartExtensions namespace.

But if you have an approach that works for you already, thats just as fine.

Thanks for that. I thought it was inside the same package. X)
It's working now. But I have to fix authorization problems with my proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: MissingAbstraction Plotly.js functionality that has to be implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants