Hi, There appears to be a bug when using custom fonts in a LogAxis:
Font font = new Font("Palatino", Font.BOLD, 18);
LogAxis axis = new LogAxis("Y Axis");
axis.setLabelFont(font);
axis.setTickLabelFont(font);
axis.setNumberFormatOverride(new DecimalFormat("0.000"));
If you comment out that last statement (setNumberFormatOverride), the custom font (Palatino) renders correctly. Also renders correctly if you use a NumberAxis. But as soon as you override the number format, the axis renders with the default font.
Seems to be an issue in all recent versions of JFreeChart.
Thoughts?
Custom font bug in LogAxis?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Custom font bug in LogAxis?
Looks like a bug and, in fact, someone already reported it before:
https://github.com/jfree/jfreechart/issues/98
I think the fix is to change the LogAxis.createTickLabel() method to start like this:
https://github.com/jfree/jfreechart/issues/98
I think the fix is to change the LogAxis.createTickLabel() method to start like this:
Code: Select all
protected AttributedString createTickLabel(double value) {
if (this.numberFormatOverride != null) {
String text = this.numberFormatOverride.format(value);
AttributedString as = new AttributedString(text);
as.addAttribute(TextAttribute.FONT, getTickLabelFont());
return as;
} else {
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

