Reputation: 51
My Y axis values on a line chart are for example ranging from 645,000 to 667,500. I would like to be able to add units to the value, such as 645K, to shorten the length of the legend.
I have seen a similar question asked, but the answer given did not provide complete code and was not very helpful.
I appreciate any help.
Upvotes: 0
Views: 676
Reputation: 205875
You can use setNumberFormatOverride()
and pass in a suitable NumberFormat
, such as the one shown here for MILLIONS
.
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setNumberFormatOverride(new NumberFormat(){…});
Upvotes: 1