Posted on 2012-04-16 14:55
yuhaibo736 阅读(1149)
评论(0) 编辑 收藏
最主要的是设置font
柱状图(CategoryPlot):
CategoryPlot plot=chart.getCategoryPlot();//获取图表区域对象
CategoryAxis domainAxis=plot.getDomainAxis();
//水平底部列表
domainAxis.setLabelFont(new Font("黑体",Font.BOLD,14));
//水平底部标题
domainAxis.setTickLabelFont(new Font("宋体",Font.BOLD,12));
//垂直标题
ValueAxis rangeAxis=plot.getRangeAxis();//获取柱状
rangeAxis.setLabelFont(new Font("黑体",Font.BOLD,15));
chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
饼图(PiePlot):
JFreeChart chart = ChartFactory.createPieChart3D("IT行业职业分布图", dataset, true, false, false);
chart.getTitle().setFont(new Font("黑体",Font.BOLD,20));//设置标题字体
PiePlot piePlot= (PiePlot) chart.getPlot();//获取图表区域对象
piePlot.setLabelFont(new Font("黑体",Font.BOLD,10));
chart.getLegend().setItemFont(new Font("黑体",Font.BOLD,10));
时序图(TimeSeries)
XYPlot plot = (XYPlot) chart.getPlot();
//纵轴字体
plot.getRangeAxis().setLabelFont(new Font("宋体", Font.BOLD, 15));
//横轴框里的标题字体
chart.getLegend().setItemFont(new Font("宋体", Font.ITALIC, 15));
//横轴列表字体
plot.getDomainAxis().setTickLabelFont(new Font("新宋体", 1, 15));
//横轴小标题字体
plot.getDomainAxis().setLabelFont(new Font("新宋体", 1, 12));
折线图
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 15));
chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
CategoryAxis domainAxis = plot.getDomainAxis();
/*------设置X轴坐标上的文字-----------*/
domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 11));
/*------设置X轴的标题文字------------*/
domainAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));
NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
/*------设置Y轴坐标上的文字-----------*/
numberaxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 12));
/*------设置Y轴的标题文字------------*/
numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12))