beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.35k stars 569 forks source link

Possibility to export really high quality images #651

Closed enricobenedos closed 2 years ago

enricobenedos commented 2 years ago

Is your feature request related to a problem? Please describe. I'm using this library to integrate it with QuestPDF. To do that I will use GetImage() method in order to obtain an SKImage from my chart and draw it to pdf.

I see that the generated image quality is very poor even if I try to save it to disk with quality:100 before. Starting from a vectorial concept normally it is possible to export very high quality images.

How can I achieve it here? For compatibility reasons I'm using beta.80 but think that nothing has been changed regarding this feature.

Describe the solution you'd like An exported image with a real high quality.

image

beto-rodriguez commented 2 years ago

Hi and thanks for the issue, I updated the QuestPDF sample to get a higher quality image, this sample will be included in the next update to the web site.

You can generate any image size setting the Width and Height properties, in the following sample I am forcing the image to have a size of 1920 x 300 and using the image inside a QuestPDF document.

Result: hello.pdf

I will close this for now, since this seems to be solved, let me know if you face an issue or something is not working properly!

enricobenedos commented 2 years ago

Hi @beto-rodriguez , thanks for your time. I already know usage of Width and Height properties but this involve in an unexpected behaviour.

The problem is that aspect ratio changes and even if the resolution is better (also the image quality), it becomes difficulty to read. Also in our example the resulting image is very difficult to read.

My question was about keep a correct aspect ratio maintaining a good image quality.

beto-rodriguez commented 2 years ago

I think you are right, my solution just hides the problem, but then we have a new one, labels are too small to read now.

There should be a way to draw on the canvas directly in Quest PDF (instead of passing the image), I will re-open to investigate this.

beto-rodriguez commented 2 years ago

With the latest version, we can draw directly on the canvas, instead of drawing an image on the canvas, this improves quality drastically.

Sample: https://github.com/beto-rodriguez/LiveCharts2/blob/dev/samples/QuestPDFSample/Program.cs

Result: hello.pdf

enricobenedos commented 2 years ago

Thank you @beto-rodriguez, this is what I meant!