服务器端/从JFReechart到图像文件的图表渲染

发布于 2025-02-12 07:10:06 字数 271 浏览 1 评论 0 原文

一个人如何从JFReechart进行编程渲染图像文件。我有用于ChartPanel的代码:是否可以直接渲染到图像 - 而无需创建AWT/GUI组件?

val chart = ..  // Imagine code to generate chart data here..
val panel = new ChartPanel(chart)
panel.renderToImage() // replace this with logic to save image file

How does one programmatically render image files from JFreeChart . I have code for ChartPanel: is it possible to render directly to an image - without creating AWT/GUI components?

val chart = ..  // Imagine code to generate chart data here..
val panel = new ChartPanel(chart)
panel.renderToImage() // replace this with logic to save image file

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任谁 2025-02-19 07:10:06

Use one of the ChartUtilities methods, such as writeChartAsJPEG() or writeChartAsPNG(), that can write to a java.io.OutputStream; or saveChartAsJPEG() or saveChartAsPNG(), that can write to a java.io.File. Some examples are seen here and here. For example,

ChartUtilities.saveChartAsPNG(new File("chart.png"), chart, width, height);

You'll also want to look into headless mode, mentioned here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文