-2

I am trying to change the font of the x-axis values (not the label) in a jfreechart bar chart.

    CategoryPlot p = chart.getCategoryPlot(); 
    final CategoryAxis axis = p.getDomainAxis();
    Font font = new Font("Dialog", Font.PLAIN, 30);
    axis.setTicklabelFont(font);

I have imported the following packages:

    import org.jfree.chart.axis.Axis;
    import org.jfree.chart.axis.CategoryAxis;
    import org.jfree.chart.axis.CategoryLabelPositions;
    import org.jfree.chart.axis.NumberAxis;

when i tried to compile the code, i am thrown with following error. Not sure which package i am missing. Or the way i am trying to change the font is wrong:

error: cannot find symbol
axis.setTicklabelFont(font);
    ^
symbol:   method setTicklabelFont(Font)
location: variable axis of type CategoryAxis
SS Hegde
  • 729
  • 2
  • 14
  • 33

1 Answers1

2

You have mispelled the method name. It's axis.setTickLabelFont(font);

Please see javadoc: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/CategoryAxis.html

Cristina_eGold
  • 1,463
  • 2
  • 22
  • 41