tags:

views:

83

answers:

1

Hello! I have a TimeSeries Chart with a XYdataset which has the milliseconds of each dates. Now I want to have a chart that only displays each date one time on the axis, no matter what the range of dates is. I already got it so far, that only the date is printed, not the time (via setNumberFormatOverride() method). What I have now, is this: alt text

What I want, is this: alt text

This is a snippet of my code. also, the setLabelAngle() method don't work?!

JFreeChart chart = ChartFactory.createTimeSeriesChart(...);
XYPlot xyplot = (XYPlot)chart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setLabelAngle(Math.PI / 6.0);`
numberaxis.setNumberFormatOverride((DecimalFormat)DecimalFormat.getInstance(Locale.GERMAN));
+1  A: 

You can set the TickUnit to any convenient DateTickUnitType. I use DAY in this example and MMM to verify the Locale:

axis.setTickUnit(new DateTickUnit(DateTickUnitType.DAY, 1,
    new SimpleDateFormat("dd.MMM.yy", Locale.GERMAN)));

As you are a returning customer, I'll address the second question, too: setLabelAngle() works perfectly well, but it changes the axis label in the chart legend. Using setVerticalTickLabels() is an alternative for the tick labels themselves:

axis.setVerticalTickLabels(true);
trashgod