Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Higher Quality of JFreeChart charts

I want to embed a PNG of a chart which I created with JFreeChart into a PDF document. The problem here is, that the quality of the chart is very poor. My goal is to have PNGs with 300 DPI. I googled for almost an hour now but I could not find a solution.

Is there a way to export the generated charts from JFreeCharts as a PNG (or a JPEG) with 300 DPI?

like image 746
Dominik Obermaier Avatar asked Oct 03 '11 17:10

Dominik Obermaier


2 Answers

Also take a look at org.jfree.chart.ChartUtilities#writeScaledChartAsPNG

If you provide a scale factor of 2, your chart will be rendered at twice the resolution.

like image 51
Alexander Malfait Avatar answered Oct 12 '22 04:10

Alexander Malfait


Since version 1.4, JFreeChart uses the png encoder provided by ImageIO. As an alternative , you might look at com.keypoint.PngEncoder, which includes setDpi(), et al. See also org.jfree.chart.encoders.SunPNGEncoderAdapter and org.jfree.chart.encoders.KeypointPNGEncoderAdapter.

like image 1
trashgod Avatar answered Oct 12 '22 04:10

trashgod