QuestPDF icon indicating copy to clipboard operation
QuestPDF copied to clipboard

Charting Libraries

Open RHaughton opened this issue 3 years ago • 10 comments

Hello,

I've been generating really nices and complex PDFs quite easily with Quest PDF and I'm glad I've found this great library.

I'm exploring Charts and have of course followed the microchart example. Unfortunately microchart is quite limited and doesn't support making a multiline Chart (which is honestly quite surprising).

I'm now exploring other charting libraries but I'm not sure if I can just use any other chart library or do I absolutely need a SKIA charting library.

I tried to find a chart library using SKIA but unfortunately I cannot find one. Where can I find one?

Can I use other charts library (for example high charts or syncfusion) and use it with QuestPDF?

Thanks for your help

RHaughton avatar Mar 25 '22 13:03 RHaughton

Hi 😁 You can use ANY charting library you want as long as it can produce an image. Then, your task is as easy as placing the image inside the PDF document using fluent API. I recommend generating the image in higher resolution (e.g. twice as high as DPI setting) so it looks sharp even when you zoom in.

However, using SkiaSharp powered libraries has additional benefits. All drawing commands performed by the library are translated into PDF commands. That means, by using this method you can achieve vector graphics that looks sharp at any zoom level and reduces file size.

MarcinZiabek avatar Mar 25 '22 23:03 MarcinZiabek

LiveCharts v2 is still in beta, but is another popular charting library that supports multiline charts.

jeffmccormick avatar Mar 27 '22 03:03 jeffmccormick

Thanks for your respoonse. I will take a look to livecharts Generally speaking, how can I find all Skia based charting libraries for C#?

RHaughton avatar Mar 28 '22 09:03 RHaughton

Generally speaking, how can I find all Skia based charting libraries for C#?

This is a hard question. The default search mechanism on the official nuget webpage does not help much as far as I see 😥

MarcinZiabek avatar Mar 28 '22 10:03 MarcinZiabek

I'm trying to find a good charting library to render as an image for questPDF (using the canvas object). I was thinking of synfusion but I'm afraid it doesn't work on the server, only on the client side.

Is there a good charting library to use with QuestPDF as an image out there?

RHaughton avatar Mar 29 '22 14:03 RHaughton

Try with OxyPlot (I have used it on my bachelors thesis and was just fine). It has a SkiaSharp engine (I have not tested it). https://www.nuget.org/packages/OxyPlot.SkiaSharp/

If you accept just images (not require pixel perfect vector graphics), just use any c# charting library that can produce an image.

MarcinZiabek avatar Mar 29 '22 14:03 MarcinZiabek

LiveCharts2 can also do this. Details here: https://github.com/beto-rodriguez/LiveCharts2/issues/16

jeffmccormick avatar Mar 29 '22 21:03 jeffmccormick

I did a combination of Chart.js and puppeteer-sharp. Handles everything I need, maybe I can give a sample when I find time.

daniel-rck avatar Apr 18 '22 09:04 daniel-rck

Hi all,

I don't know if this is helpful, but I like to use ScottPlot for plots and charts.

Official Site: https://scottplot.net NuGet: https://www.nuget.org/packages/ScottPlot/

pespinho avatar May 09 '22 17:05 pespinho

There is a sample for LiveCharts2, it will be included in the site in a future version of the docs:

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

beto-rodriguez avatar Aug 16 '22 18:08 beto-rodriguez