更高质量的 JFreeChart 图表
我想将使用 JFreeChart 创建的 PNG 图表嵌入到 PDF 文档中。这里的问题是图表的质量很差。我的目标是拥有 300 DPI 的 PNG。我用谷歌搜索了将近一个小时,但找不到解决方案。
有没有办法将 JFreeCharts 生成的图表导出为 300 DPI 的 PNG(或 JPEG)?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另请查看 org.jfree.chart.ChartUtilities#writeScaledChartAsPNG
如果您提供的比例因子为 2,您的图表将以两倍的分辨率呈现。
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.
从版本 1.4 开始,
JFreeChart
使用png
由ImageIO
。作为替代方案,您可以查看com.keypoint.PngEncoder< /code>
,其中包括
setDpi()
等。另请参阅org.jfree.chart。 encoders.SunPNGEncoderAdapter
和org.jfree.chart.encoders.KeypointPNGEncoderAdapter< /代码>
。
Since version 1.4,
JFreeChart
uses thepng
encoder provided byImageIO
. As an alternative , you might look atcom.keypoint.PngEncoder
, which includessetDpi()
, et al. See alsoorg.jfree.chart.encoders.SunPNGEncoderAdapter
andorg.jfree.chart.encoders.KeypointPNGEncoderAdapter
.您可以使用 XChart 来实现此目的,因为以高分辨率导出
图表
某些 DPI 是自版本 2.2.0 以来的新功能。代码看起来像这样:免责声明:我是 XChart 的首席开发人员。我最近遇到了和你完全相同的问题。我需要 300 DPI 的图表来制作科学出版物。欢迎反馈!
You could use XChart for this, as exporting
Charts
in high-res at a certain DPI is a new feature since version 2.2.0. The code would look something like this:Disclaimer: I'm the lead developer of XChart. I recently faced the exact same problem as you. I needed charts at 300 DPI for a scientific publication. Feedback is welcome!