I can't find how to modify the label of the y axis.
For now I use a TimeSeries with the MINUTE class, and then insert the TimeSeries into a Dataset.
It look like this :
final TimeSeries s1 = new TimeSeries("Importation Time", Minute.class);
s1.add(new Minute(dateFinal),concateHourAndMinuteToGetASingleValue);
dataset.addSeries(s1);
What I would like to do is to modify the display label, and put a String (05h20 for exemple) instead of the Double value.
Any help would be much appreciated :)
Thank you!
You will need to set a FormatOverride
on the axis
.
Here is an example for both a NumberAxis
and 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"));