日期:2014-05-17 浏览次数:21115 次
JFreeChart chart = ChartFactory.createBarChart("企业风险度等级统计图", // 图表标题
"企业风险度等级", // 目录轴的显示标签
"企业风险度等级个数", // 数值轴的显示标签
getPillarDateSet(riskLevelList, sum), // 数据
// PlotOrientation.HORIZONTAL, //图表方向水平
PlotOrientation.VERTICAL, // 图表方向垂直
true, // 是否显示图例
false, // 是否显示工具提示
false // 是否生成URL
);
// 设置标题及标题字体
chart.setTitle(new TextTitle("企业风险度等级统计图",
new Font("宋体", Font.BOLD, 18)));
//设置图例文字
chart.getLegend().setItemFont(new Font("宋体", Font.BOLD, 12));
// 获取柱状图plot对象
CategoryPlot plot = (CategoryPlot) chart.getPlot();
// 设置柱型的颜色
plot.getRenderer().setSeriesPaint(0, Color.blue);
plot.setNoDataMessage("抱歉,没有查到相关的数据...");
// 取得横轴
CategoryAxis categoryAxis = plot.getDomainAxis();
// 设置横轴的字体
categoryAxis.setLabelFont(new Font("sans-serif", Font.BOLD, 18));
// 设置分类标签以45度倾斜
// categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// 设置分类标签字体
categoryAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 15));
// 取得纵轴
NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
// 设置纵轴的字体
numberAxis.setLabelFont(new Font("宋体", Font.BOLD, 18));
BarRenderer3D renderer = new BarRenderer3D();
// 显示每个柱的数值,并修改该数值的字体属性
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(