【发布时间】:2014-02-19 12:20:30
【问题描述】:
我的目标是增加“Revenue ($)”和“Years”的大小。但是我不知道怎么做。我可以增加“Apples, Durians,Oranges”和“2012, 2013”。
以下是我的代码。
JFreeChart chart = ChartFactory.createBarChart3D("", // chart title
"Years", // domain axis label
"Revenue ($)", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
false, // tooltips
false);
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis axis = plot.getDomainAxis();
CategoryPlot p = chart.getCategoryPlot();
ValueAxis axis2 = p.getRangeAxis();
Font font = new Font("Dialog", Font.PLAIN, 25);
axis.setTickLabelFont(font);
Font font2 = new Font("Dialog", Font.PLAIN, 15);
axis2.setTickLabelFont(font2);
LegendTitle legend = new LegendTitle(plot.getRenderer());
Font font3 = new Font("Dialog", Font.PLAIN, 20);
legend.setItemFont(font3);
legend.setPosition(RectangleEdge.BOTTOM);
chart.addLegend(legend);
【问题讨论】:
-
找到答案的最快方法是阅读 API 文档 (jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/…) 并扫描所有 setXXX() 方法(包括继承的方法)。 setLabelFont() 应该是值得一试的。
标签: java jfreechart font-size axis-labels