我正在尝试更改jfreechart条形图中x轴值(而不是标签)的字体。
CategoryPlot p = chart.getCategoryPlot();
final CategoryAxis axis = p.getDomainAxis();
Font font = new Font("Dialog", Font.PLAIN, 30);
axis.setTicklabelFont(font);
我导入了以下软件包:
import org.jfree.chart.axis.Axis;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
当我尝试编译代码时,我被抛出以下错误。不确定我错过了哪个套餐。或者我试图改变字体的方式是错误的:
error: cannot find symbol
axis.setTicklabelFont(font);
^
symbol: method setTicklabelFont(Font)
location: variable axis of type CategoryAxis
答案 0 :(得分:2)
您拼错了方法名称。 ' s axis.setTickLabelFont(font);
请参阅javadoc: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/CategoryAxis.html