5 day chart(Time Series)

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

5 day chart(Time Series)

Post by RaviTeja » Tue May 21, 2002 3:15 pm

Hello,

I wish some would help me.
I'm trying to generate a 5day chart(Time Series).
I will have the data for each of the five days and that particular point must be plotted on graph.
As,i'm trying to genarate a graph for the trading of shares in the share market,i'll not have values on holidays (saturdays ,sundays,public holidays).
but on the graph the data that is not available is also being taken into account if the date falls between the range of dates fetched from the database.
to be more clear, suppose if i have a data for 15th may,2002,
16th may 2002,17th may 2002,19th may 2002 and 20th may 2002.
in between i have no data for 18th may.
but the graph is taking the value for 18th may also and this particular date is also appeared on the x-axis label.
but i don't want this value.
i hope some one can get me solution for this

RaviTeja

Re: 5 day chart(Time Series)

Post by RaviTeja » Tue May 21, 2002 3:37 pm

Hi..........

i would like to have on my x-axis cooridinates to be 12/03
instead of having having 12-mar-2002.
the problem exists when the graph area is small say 200*200.
the coordinates are getting overlapped
pl get me the solution for this.
bye and thanks in advance
regards
ravi teja

RaviTeja

Re: 5 day chart(Time Series)

Post by RaviTeja » Tue May 21, 2002 3:41 pm

and also if i possess five values then the 6th coordinate is coming to picture
on the x-axis intsead of five.
to be more clear one extra x-coordinate is coming to picture than the number of values i have........

Mudit Wahal

Re: 5 day chart(Time Series)

Post by Mudit Wahal » Tue May 21, 2002 3:55 pm

David,

Seems like lot of people are trying to use JFreeChart for stock charts and everything is having the same problem I had (and may be people before me). I dont know how others solved the problem of Day class trying to insert the missing days on the x-axis. And if they did, I didnt see anyone sharing it.

Ravi,

As long as you are using any TimePeriod based classes (such as Day, Hour, Second etc etc), you will have missing dates appearing in the x-axis. The reason is these classes are not tied to the y-values. So, if you have may 17th and may 19th in the Day class, and try to plot it, it plots may 17th and then may 17th.next() which is May 18th and then may 18th.next() which is may 19th. It doesn't see or care if you have data for may 18th or not. Even worse, if you have a weekend or a 3 day weekend like the one coming up next week. Then you have 2/3 days of blank bars.

The solution is to have your own class to handle the date printing on x-axis, extend numberAxis, and any dataset you are using. In your extended numberAxis, handle refreshTicks() and call your dataset method to provide the labels.

Hope it helps.

Thanks
Mudit

David Gilbert

Re: 5 day chart(Time Series)

Post by David Gilbert » Tue May 21, 2002 8:12 pm

Mudit Wahal wrote:
>
> David,
>
> Seems like lot of people are trying to use JFreeChart for
> stock charts and everything is having the same problem I had
> (and may be people before me). I dont know how others solved
> the problem of Day class trying to insert the missing days on
> the x-axis. And if they did, I didnt see anyone sharing it.

Hi Mudit,

I'm aware of the requirement...at the moment the HorizontalDateAxis is just a real time line, with no ability to skip time periods.

In the future I will implement something along the lines of a TradingDateAxis that understands the concept of trading sessions (one or several time periods per day when trading is open) and holidays (I have some classes in the JFinance library that could help out here).

But there is enough work in that to ensure that it won't be included in the next release.

Regards,

DG.

P.S. By the way, the Day class doesn't interact with the axis at all (at least not in terms of setting the tick labels), it just returns a value (the number of milliseconds since 1 Jan 1970) and the date axis decides where to plot the data point given it's current range.

The tick labels are determined only by the current tick unit for the axis (which you can have auto-selected to ensure that the labels on the axis don't overlap, or you can manually set it to whatever you require).

Locked