您将需要FormatOverride
在axis
.
这是 aNumberAxis
和 a的示例DateAxis
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setNumberFormatOverride( new NumberFormat(){
@Override
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
return new StringBuffer(String.format("%f", number));
}
@Override
public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
return new StringBuffer(String.format("%f", number));
}
@Override
public Number parse(String source, ParsePosition parsePosition) {
return null;
}
} );
DateAxis domainAaxis = (DateAxis) plot.getDomainAxis();
domainAaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));