Skip to content
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

Convert ChartJSCore.Models.Chart to image #14

Closed
MrVine opened this issue Mar 3, 2018 · 1 comment
Closed

Convert ChartJSCore.Models.Chart to image #14

MrVine opened this issue Mar 3, 2018 · 1 comment
Assignees
Labels

Comments

@MrVine
Copy link

MrVine commented Mar 3, 2018

Hello! Your library is awesome, I have experience of use it in ASP.NET Core MVC project, but currently I want to use it in ASP.NET WebApi project to generate charts on a server-side.

Question: is it possible to convert instance of Chart class to some type of image (like png, jpg or something like this) in base64 format or in byte[] ?
Thank you.

@mattosaurus
Copy link
Owner

Hi @MrVine, the actual rendering of the chart takes place in the browser and is done by the chart.js plugin, ChartJSCore only generates the code for chart.js and doesn't actually do any of the rendering itself.

It seems like it is possible to get a byte[] from a rendered chart.
https://stackoverflow.com/questions/20206038/converting-chart-js-canvas-chart-to-image-using-todataurl-results-in-blank-im
but I don't think this is what you're after as you'd need to first render the chart on a page before getting the byte[] for it and then return this from your API which would be pretty convoluted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants