Dataset for a Line Chart...

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

Dataset for a Line Chart...

Post by George » Sun Jul 28, 2002 11:04 pm

I have stored my financial data in 7 arrays Date[], double[], double[].... (date, open,high, low,close,volume).

What I am trying to do is to get a a simple time series chart . My problem is that i dont understand how to feed a "Dataset". I can make it with HighLowDataset which asks for arrays as its arguments but this way it takes the first series (open) to print the y-axis.

Ideally, I would like a line chart with x=date and y=close.

Anyone that could help me to do it using the correct way ?


Many thanks
George

David Gilbert

Re: Dataset for a Line Chart...

Post by David Gilbert » Mon Jul 29, 2002 9:41 am

Hi George,

The DefaultHighLowDataset class returns the 'close' value in the getYValue method. It's the only implementation of the HighLowDataset interface at present, but you can also write your own class that implements the HighLowDataset interface.

Regards,

DG.

George

Re: Dataset for a Line Chart...

Post by George » Mon Jul 29, 2002 2:35 pm

Thank you David !


From what I can figure out, I can use the HighLowDataset and change the type of chart from line to candles just by changing the Renderer (StandartXYRenderer and CandlestickRendererRenderer).

and something else about these types of chart...
Is it possible to set the y-axis in semi-logarithmic scale ?



thanks again,

George

David Gilbert

Re: Dataset for a Line Chart...

Post by David Gilbert » Mon Jul 29, 2002 11:05 pm

The HighLowDataset interface extends the XYDataset interface, so you can use the former anywhere that the latter is valid. In the DefaultHighLowDataset class, the getYValue(...) method is coded to return the same value as the getCloseValue(...) method.

There are logarithmic axes that can be used to replace any numerical axis. You would do something like this:

VerticalLogarithmicAxis rangeAxis = new VerticalLogarithmicAxis("Log(value)");
plot.setRangeAxis(rangeAxis);

I have been sent some updates to the log axis code which should make it into CVS some time next week (I'm fairly short on time this week).

Regards,

DG.

Locked