#1113 LogarithmicAxis: number formatting differs from NumberAxis

1.0.x
open
nobody
None
5
2013-06-18
2013-06-18
No

While the NumberAxis it is derived from formats tick labels as "1,000", LogarithmicAxis tick labels show as "1000". There are multiple causes for this:

1) NumberAxis has a default TickUnit that uses new DecimalFormat("0") while it should maybe better use NumberFormat.getInstance().

2) While NumberAxis usually replaces this default TickUnit with one from its standardTickUnits, LogarithmicAxis never changes the default (it ignores any set standardTickUnits).

3) A vertical LogarithmicAxis doesn't even use the default TickUnit but Long.toString().

A workaround to make LogarithmicAxis format tick labels as NumberAxis does (JFreeChart 1.0.14):

// horizontal LogarithmicAxis only
axis.setTickUnit(new NumberTickUnit(1.0, NumberFormat.getInstance(locale)), false, false);

// vertical LogarithmicAxis only
axis.setNumberFormatOverride(NumberFormat.getInstance(locale));

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks