XYChart with X Axis displaying hour of night?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Allan Brighton

XYChart with X Axis displaying hour of night?

Post by Allan Brighton » Sat Mar 01, 2003 5:37 am

Hi all,

I want to display an XY line chart plotting the elevation of some stars during the night. So the X axis should display values between 0 and 24. The problem I have is that if the hour value wraps around to 0 in the middle of the X axis, then the chart looks wrong.
I thought about using the Hour class instead of doubles, but the Hour class only allows integers, where I need a better resolution. Also the X axis should display just the hours, and not hours:min:sec.

Any tips on how to do this?

Thanks in advance?

David Gilbert

Re: XYChart with X Axis displaying hour of night?

Post by David Gilbert » Tue Mar 04, 2003 10:16 am

Hi Allan,

With the TimeSeries class, if you have one observation per hour (missing observations are permitted) then the Hour class is fine. If you want better resolution, then you can use the Minute, Second, or Millisecond classes for the time period...always keeping in mind that missing observations are permitted (for example, using the Minute class you could add data values at 10:11pm, 10:27pm, 10:28pm, 10:59pm, 11:02pm...).

Note also that the Hour, Minute, Second and Millisecond classes carry date information with them, so your data can span midnight and the plot will still know that 11:59pm should appear before 12:01am the next day.

The date axis will try to select a tick label format that is appropriate for the data values being displayed, but it isn't perfect. You can override the format in several ways:

- use the setDateFormatOverride(...) method in the DateAxis class;
- use the setTickUnit(...) method in the DateAxis class;
- use the setStandardTickUnits(...) method in the ValueAxis class;

Regards,

Dave Gilbert

Locked