I'm trying to set the font of my chart's x-axis in this manner:
CategoryPlot plotCat = (CategoryPlot) chart.getPlot();
CategoryAxis xAxis = plotCat.getDomainAxis();
Font font = new Font("SanSerif", Font.STRIKETHRU, 3);
//or Font font = new Font(Font.FontFamily.HELVETICA, 3, Font.BOLD);
xAxis.setTickLabelFont(font);
//or xAxis.setLabelFont(font);
This is the solution that I keep reading about but it doesn't work for me. I keep getting the messages: The method setTickLabelFont(Font) in the type Axis is not applicable for the arguments (Font)
and The method setLabelFont(Font) in the type Axis is not applicable for the arguments (Font)
.
What is going on that is not allowing me to apply a different font to these labels?
It's possible that it's because I'm importing com.itextpdf.text.Font
instead of java.awt.Font
, but com.itextpdf.text.Font
is necessary to set the font of other elements in the PDF. How do I resolve these differences if this is indeed the cause of the problem?