I'm using JfreeChart 1.0.13 to display a CombinedDomainXYPlot with price data using a line chart on top and a bar chart displaying volume data underneath.
Since the volumes can be quite large (eg 60 million) a lot of space is being used for the range axis labels.
Is there any way to display the tick labels in millions - for example to display 6m instead of 6,000,000?
thanks
Dave
Displaying range axis tick labels in millions
-
- Posts: 9
- Joined: Tue Jul 06, 2010 7:10 pm
- antibot: No, of course not.
Re: Displaying range axis tick labels in millions
You could try something like this:
Code: Select all
rangeAxis.setNumberFormatOverride(new DecimalFormat() {
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
if (number >= 1000000) {
toAppendTo.append((int)(number / 1000000));
toAppendTo.append("m");
}
else if (number >= 1000) {
toAppendTo.append((int)(number / 1000));
toAppendTo.append("k");
}
else {
toAppendTo.append((int)number);
}
return toAppendTo;
}
});
-
- Posts: 9
- Joined: Tue Jul 06, 2010 7:10 pm
- antibot: No, of course not.
Re: Displaying range axis tick labels in millions
Works like a charm - many thanks!
Dave
Dave