2
votes

I am using JFreechart to create a Gantt chart, however the Date (X-axis) is being displayed in the Date format HH:MM:SS.

Is there any way to get this x-axis to only display milliseconds? Since this is a Gantt chart my x-axis values are of type SimpleTimePeriod which I constructed with milliseconds.

Thank you very much for any help.

2

2 Answers

3
votes

Assuming ChartFactory.createGanttChart(), you can specify any desired format when calling setNumberFormatOverride() on the plot's DateAxis. There's a related example here.

0
votes

This also works:

CategoryPlot plot = (CategoryPlot) chart.getPlot(); 
DateAxis range = new DateAxis("Date");
range.setDateFormatOverride(new SimpleDateFormat("ss.SSS"));
plot.setRangeAxis(range);