我是 jfreechart 的菜鸟,我有一个应用程序可以创建一个运行良好的简单条形图。问题是,我希望所有图表显示 1 到 10 的范围。当图表中的最高 val 低于此值时,该较低值将是图表的上限,并且将以不同的增量显示。从在线笔记中我不清楚在哪里改变它....
DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
System.out.println("Setting values:");
barDataSet.setValue(rating.getFlavor(), "category", "Flavor");
barDataSet.setValue(rating.getBody(), "category", "Body");
barDataSet.setValue(rating.getAftertaste(), "category", "Aftertaste");
barDataSet.setValue(rating.getSweetness(), "category", "Sweetness");
barDataSet.setValue(rating.getFloral(), "category", "Floral");
barDataSet.setValue(rating.getSpice(), "category", "Spice");
JFreeChart chart = ChartFactory.createBarChart(null, // title
"category", // left heading
"score", // top heading
barDataSet, // dataset
PlotOrientation.HORIZONTAL,
false, // no idea what this is
true, // or this
false); // or this
System.out.println("setting bg color");
Color bgcolor = new Color(237, 232, 228);
chart.setBackgroundPaint(bgcolor);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(new Color(112,112,112) );
谢谢,bp