从 JFreeChart 到图像文件的服务器端/非交互式图表渲染
Server-side/ non-interactive rendering of Charts to image files from JFreeChart
如何以编程方式呈现来自 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
使用 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 之一。例如,
ChartUtilities.saveChartAsPNG(new File("chart.png"), chart, width, height);
您还想研究无头模式,提到了 here。
如何以编程方式呈现来自 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
使用 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 之一。例如,
ChartUtilities.saveChartAsPNG(new File("chart.png"), chart, width, height);
您还想研究无头模式,提到了 here。