I am trying to format the y-axis of charts I am creating (JFreeCharts)
DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
df.setMaximumFractionDigits(5);
numberTickUnit = new NumberTickUnit(numberTickUnit.getSize(), df);
Some charts have a range from say 0-15, so I want the numbers to have 2 decimals. Some charts have a range from 0.001 to 0.002, so I want the numbers to have 5 decimals.
The code above works well, with 1 issue. I want all the numbers on the axis to have the same format (the maximum number of decimals). So if I have 0.01251, 0.02000, 0.27490
, I want it to display like that, as opposed to 0.01251, 0.02, 0.2749
. How do I make the entire axis have the same format, instead of setting it separately for each number.