Intraday XYchart

Discussion about JFreeChart related to stockmarket charts.
Locked
williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Intraday XYchart

Post by williamt » Thu Dec 14, 2006 1:37 pm

Hi folks,
I'm having a trouble displaying intraday stock market info.
I get the data from my data base, with the date and the value of the stock using a JDBCXYDataset, and it works fine.
Here in Brazil, the market opens at 9:00AM and closes at 6:00PM, and I get the data each 15 minutes.
When I plot a xylinechart, between the days, the graph has a "gap", showing a straight line.
I'm trying to use SegmentedTimeline, but I can't get it to work.
Here's what I'm doing:
Get the JDBCXYDataset from my database, basically 1 column with the date, and 2 more with data from a stock and then I create a JFreeChart.
Then I'm getting the plot from the jfchart, creating a new DateAxis, setting the range based on the x axis value, and then use this code to set the Timeline:

Code: Select all

public static SegmentedTimeline newFifteenMinuteTimeline() { 
            SegmentedTimeline timeline = new SegmentedTimeline(SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE, 36, 60); 
            timeline.setStartTime( 
                timeline.FIRST_MONDAY_AFTER_1900 + (36 * timeline.getSegmentSize()) - TimeZone.getDefault().getDSTSavings()  
            ); 
            timeline.setBaseTimeline(timeline.newMondayThroughFridayTimeline()); 
            return timeline; 
        } 
then I set this new DateAxis to be the DomainAxis of the plot.

Hope you can help me!

Thanks in advance!
William

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Fri Dec 15, 2006 2:08 pm

Hi,
Im using SegmentedTimeline and it's working.
But i'm trying now to skip weekends, and it does not work with fifteenMinuteTimeLine...
I've tryed every single method I found in this forum, but none of them worked for me.
Does anyone who made this work have any tips making this work?

Thanks!

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Tue Dec 26, 2006 5:26 pm

Anyone?!
I really need this working!

Thanks!

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Fri Mar 09, 2007 6:49 pm

BumP!

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Fri Mar 09, 2007 8:34 pm

try this, that might help, this is coded for US based timezone.

Code: Select all

DateAxis axis = new DateAxis();
long FIFTEEN_MINUTE_SEGMENT_SIZE = 15 * 60 * 1000;
SegmentedTimeline timeline = new SegmentedTimeline(FIFTEEN_MINUTE_SEGMENT_SIZE,26,70);
timeline.setStartTime(SegmentedTimeline.FIRST_MONDAY_AFTER_1900 +
        (38 * timeline.getSegmentSize()));
timeline.setBaseTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 9);
cal.set(Calendar.MINUTE, 30);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date from = cal.getTime();

cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, 16);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date to = cal.getTime();
timeline.addBaseTimelineExclusions(from.getTime(),to.getTime());
Hope this helps.

Locked