1

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 http://dl.getdropbox.com/u/1144075/Bildschirmfoto%202010-08-05%20um%2016.51.39.JPG

What I want, is this: alt text http://dl.getdropbox.com/u/1144075/Bildschirmfoto%202010-08-05%20um%2016.54.54.JPG

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));
tzippy
  • 6,458
  • 30
  • 82
  • 151

1 Answers1

2

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
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    axis.setVerticalTickLabels(true) displays the labels vertically. If you want to change the angle of the tick labels at 45 degrees, let's say, then setLabelAngle() will be of no use for DateAxis. – sufinawaz Jun 17 '13 at 21:39