Setting date range in Time series horizontal axis

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

Setting date range in Time series horizontal axis

Post by Eric Lo » Tue Feb 20, 2001 5:31 pm

Hi all JFreeChart user,
I am now working on a time series chart which display price of a stock in Y-axis, and X-axis should be date. However, as the range of X-axis is about 2 years. The JFreeChart display a tick every 3 months automatically! But I want the tick to be 1 month (or customize), but I can't find any solution, could any one help?

Also, as I am now implement a stock price quote in multiple time series thru servlet. Despite the above problem, I was 90% finished and I want to submit my code here to thanks David, do anyone know that the submission procedure?

Thanks x1000!!!
Eric

(Urgent)

David Gilbert

RE: Setting date range in Time series horizontal a

Post by David Gilbert » Wed Feb 21, 2001 9:47 pm

Hi Eric,

By default, JFreeChart works out tick units automatically by trying to show as many ticks as possible without the labels overlapping. Most of the time, this is OK.

If you want to control the tick units yourself, you need to do something like this:

DateAxis myHorizontalAxis = (DateAxis) myPlot.getAxis(Plot.HORIZONTAL_AXIS);
myHorizontalAxis.setAutoTickValue(false);
myHorizontalAxis.setTickUnit(new DateUnit(Calendar.MONTH, 1));

(I've not actually compiled and run this, but it should work! Let me know if it doesn't)

To submit code to the project, you can just e-mail me the source files and I'll incorporate them into the source tree. Or you can sign up as a developer on SourceForge, join the JFreeChart project, I'll give you write access to the CVS repository and you can add the code yourself.

Lot's of developers have asked about using JFreeChart in servlets, so it would be great if you sent in your code...

Regards,

DG.

Locked