我正在尝试使用JFreeChart获取条形图。
final DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
dataSet.setValue(1.0, "OS", "Ubuntu");
dataSet.setValue(2.0, "OS", "Linux");
dataSet.setValue(1.0, "OS", "Windows");
JFreeChart jFreeChartObj = CreateBarChart.createBarChart(chartDetails);
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(response.getOutputStream(), jFreeChartObj, 500, 500);
我收到了这样的错误:
java.lang.NullPointerException
at org.jfree.chart.plot.CategoryPlot.draw(CategoryPlot.java:2291)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1041)
at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1224)
at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1204)
at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:174)
at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:120)