我试图在我的应用程序中实现jfreechart我在jfree中提到了一些例子 网站。但我需要一个像google's column chart这样的图表 。我怎样才能在jfreecharts中获得这种类型的图表。
答案 0 :(得分:0)
使用它来获取jfreecharts中的类似图表
String Male1 = "First";
String Male2 = "sec";
String Female1 = "Category 1";
String Female2 = "Category 2";
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(10, Male1, Female1);
dataset.addValue(12, Male1, Female2);
dataset.addValue(22, Male2, Female1);
dataset.addValue(50, Male2, Female2);
final JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart Demo", "Category", "Score", dataset,
PlotOrientation.VERTICAL, true, true, false);
BarRenderer br = new BarRenderer();
br.setItemMargin(0.0);
chart.getCategoryPlot().setRenderer(br);
try {
ChartUtilities.saveChartAsPNG(new File("E:\\jfreeBarchart.png"), chart, 500, 500);
System.out.println("=====chart=====");
} catch (Exception e) {
e.printStackTrace();
}