Is it possible to use a HorizontalCategoryAxis for dates? Se

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

Is it possible to use a HorizontalCategoryAxis for dates? Se

Post by BH » Tue Aug 27, 2002 11:03 am

Hi there

I am creating a 7 day price graph. The 7 days are for 7 trading days - i.e. not Saturday and Sunday. Note: there will be no data for the Saturday and Sunday - the value for these days will be the same as Friday.

I would like to display the day of the week on the x axis - eg:

Wed Thu Fri Mon Tue Wed Thu

would be 7 days. However, the Sat and Sun are put in and interpolated. I am using a HorizonatalDateAxis. I don't want the Sat and Sun put in, because it gives a false impression that the price is moving over the weekend, when in fact it is the same as the Friday and only changes on the Monday.

I have tried using a CategoryAxis to do this instead of the HorizontalDateAxis but I am struggling. I am not sure this is a good thing to do anyway, because I have date objects on the x axis.

Is it possible to do what I am trying to do? What would be the best way to do it using the existing software?

Many thanks
Belinda

David Gilbert

Re: Is it possible to use a HorizontalCategoryAxis for dates

Post by David Gilbert » Tue Aug 27, 2002 10:01 pm

Hi Belinda,

At the moment, you either have to add null to your dataset for Saturday and/or Sunday (this will cause a break in the line representing your data, the days will still appear on the axis), or...

You could switch to a line chart based on a CategoryDataset and use the HorizontalCategoryAxis.

Neither solution is great...eventually I'd like to create an extended date axis that can skip non-trading days.

Regards,

DG.

BH

Re: Is it possible to use a HorizontalCategoryAxis for dates

Post by BH » Wed Aug 28, 2002 9:07 am

Hi David

Thanks for the reply. I am trying to use the HorizontalCategoryAxis now.

I am using a CategoryDataset to load the data now. What type of Plot and what type of Renderer should I be using. I started using a VerticalCategoryPlot because this takes in a CategoryDataset in its constuctor. However, it requires a CategoryItemRenderer and I don't know which one to use.
I can get this to compile (using a LineAndShapeRenderer which doesn't sound right to me), but I get loads of 'bad path' exceptions when trying to run it....

Many thanks for your help

Belinda

David Gilbert

Re: Is it possible to use a HorizontalCategoryAxis for dates

Post by David Gilbert » Wed Aug 28, 2002 10:47 am

The createLineChart(...) method in the ChartFactory class is one way to create a line chart based on a CategoryDataset. There's about five lines of code in the method that pulls together the pieces for the chart...just for convenience.

Regards,

DG.

Locked