生成图表的错误
public class BarCharDemo {
public static void main(String[] args) throws
IOException {
CategoryDataset dataset= getDataSet();
JFreeChart chart=ChartFactory.createBarChart3D( "水果产量图 ",
"水果 ",
"产量 ",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false);
FileOutputStream a=null;
try{
a=new FileOutputStream( "D:\\ProjectBudget\\css\\log.jpg ");
ChartUtilities.writeChartAsJPEG(a,100,chart,400,300,null);
}finally{
try{
a.close();
}catch(Exception e){}
}
}
private static CategoryDataset getDataSet(){
DefaultCategoryDataset dataset= new DefaultCategoryDataset();
dataset.addValue(100,null, "苹果 ");
dataset.addValue(200,null, "梨子 ");
dataset.addValue(300,null, "香蕉 ");
dataset.addValue(400,null, "葡萄 ");
dataset.addValue(500,null, "桃子 ");
return dataset;
}
}
这是程序,报错是:
Null 'key ' argument
请问大家,哪里有错啊 多谢
------解决方案--------------------private static CategoryDataset getDataSet(){
DefaultCategoryDataset dataset= new DefaultCategoryDataset();
dataset.addValue(100,苹果 ",200);
dataset.addValue(200,梨子 ",100);