Better JFreeChart Charts

I want to insert a PNG chart that 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 PNG with 300 DPI. I've been google for almost an hour, but I could not find a solution.

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

+5
source share
3 answers

Starting with version 1.4, it JFreeChartuses the encoder pngprovided ImageIO. Alternatively, you can view com.keypoint.PngEncoderwhich includes setDpi()and others. See. It is also org.jfree.chart.encoders.SunPNGEncoderAdapter, and org.jfree.chart.encoders.KeypointPNGEncoderAdapter.

+1
source

XChart , Charts high-res DPI - , 2.2.0. :

double[] xData = new double[] { 0.0, 1.0, 2.0 };
double[] yData = new double[] { 2.0, 1.0, 0.0 };

// Create Chart
Chart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData);

// Show it
new SwingWrapper(chart).displayChart();

// Save it
BitmapEncoder.savePNG(chart, "./Sample_Chart.png"); // default 72 DPI
BitmapEncoder.savePNGWithDPI(chart, "./Sample_Chart_300_DPI.png", 300);

: XChart. , . 300 DPI . !

0

All Articles