How to add Duplicate Values In Time-Series

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

How to add Duplicate Values In Time-Series

Post by ranjeet » Tue Sep 17, 2002 5:08 am

Hi..
I am using JFreechart for displaying my Price/Volume charts. I am having one major problem in doing that. I have duplicate values for x-axix. for example date value for x-axix are same some times and when i try to put these dupliate values I get exception Like Time Series aleardy exists.
I have tried a lot on this but could not get any solution. Please suggest me any way out .
waiting for some positive response
regards
ranjeet

David Gilbert

Re: How to add Duplicate Values In Time-Series

Post by David Gilbert » Tue Sep 17, 2002 4:42 pm

Hi Ranjeet,

Can you give me an example of how you are using the duplicate values?

The BasicTimeSeries class throws an exception if you try to add another data value to the same TimePeriod, because that's the behaviour I need for my code.

It might be possible to add an 'allowDuplicates' flag in the same way as has been done for XYSeries, but I'd need to understand more about what you are doing first...

Regards,

DG.

ranjeet

Re: How to add Duplicate Values In Time-Series

Post by ranjeet » Wed Sep 18, 2002 5:01 am

Hi..
Thanks for your response. First i will explain you about my problem in details.
Actually i need Price/Volume chart of jfreechart to be used in my web application. I need this graph in the same way as the example with download. for examples i need price portion to be shown as in example and vaolume to be shown as bars. But my problem is that I have data values for same TimePeriod which when i try to add to BasicTimeSeries class, gives me the duplicate values exception.
BasicTimeSeries series1= new BasicTimeSeries("Price", Day.class);
series1.add(new Day(new Date(2002, 3,1)), 12353.3);
series1.add(new Day(new Date(2002, 3,1)), 13984.3);
series1.add(new Day(new Date(2002, 3,3)), 12999.4);
series1.add(new Day(new Date(2002, 3,3)), 14274.3);
series1.add(new Day(new Date(2002, 3,5)), 15943.5);

Please suggest me how i can do this ..
regrads
ranjeet

David Gilbert

Re: How to add Duplicate Values In Time-Series

Post by David Gilbert » Wed Sep 18, 2002 7:43 am

You can use other subclasses of TimePeriod, like Hour, Minute, Second or Millisecond (only one type per series). This will help to avoid duplicate values.

Regards,

DG

ranjeet

Re: How to add Duplicate Values In Time-Series

Post by ranjeet » Thu Sep 19, 2002 5:42 am

Hi..
Thanks for support. I am really getting great help from you . I tried option you gave to me but i am not getting it. Please can you try some sample code for me. just try to add same date values to volume and price and if the output comes the same as given in jfree chart sample then i will be through.. Hope to get nice solution from your side
regards
ranjeet

Locked