Issue in plotting Price volumne chart

Discussion about JFreeChart related to stockmarket charts.
Locked
abhay.asingh
Posts: 58
Joined: Mon Dec 15, 2008 7:07 am
Location: India
Contact:

Issue in plotting Price volumne chart

Post by abhay.asingh » Thu Jan 14, 2010 6:00 am

Hi,

I am making price volume chart, and it was working fine, but now my data set is changed and time range is now 09:00 hrs to 16:00 hrs(previously it was 10:00 t0 16:00 hrs).
Now i can't see initial points in my chart means data from 9 to 10, once i get data for 10:00 hrs onwards i can see.
I don't know where i am doing wrong, may be because of my SegmentedTimeline() implementation.
Here is code i am using to make X-Axis(Date time)

Code: Select all

DateAxis dateaxis = new DateAxis("Time");
setTimeFormat(report, dataset[0], dateaxis);
The implementation of setTimeFormat() method is

Code: Select all

 private static int MILLISECS_PER_DAY = 86400000;

        private static void setTimeFormat(Report report, Dataset dataset, DateAxis dateaxis) {
                TimeSeriesCollection tscoll = (TimeSeriesCollection) dataset;
                double domainRange = tscoll.getDomainUpperBound(false) - tscoll.getDomainLowerBound(false);
                int domainDays = (int) (domainRange / MILLISECS_PER_DAY);
                if (domainDays < 10) {  // One day chart.
                        dateaxis.setTimeline(tl);
                        if (domainDays < 3)
                                dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
                        else {
                                dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1));
                                dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
                                dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-dd"));
                        }
                } else {
                        dateaxis.setTimeline(default_tl);
                }
                dateaxis.setLowerMargin(0D);
                dateaxis.setUpperMargin(0D);
        }

        private static SegmentedTimeline initnewFifteenMinuteTimeline() {
                SegmentedTimeline tl = new SegmentedTimeline(SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE, 24, 72);
                tl.setBaseTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
                tl.setStartTime(SegmentedTimeline.firstMondayAfter1900() + 40 * tl.getSegmentSize());
                final Calendar cal2 = Calendar.getInstance();
                cal2.set(Calendar.HOUR_OF_DAY, 16);
                cal2.set(Calendar.MINUTE, 30);
                cal2.set(Calendar.SECOND, 0);
                cal2.set(Calendar.MILLISECOND, 0);
                final Calendar cal = (Calendar) cal2.clone();
                cal.add(Calendar.YEAR, -1);

                tl.addBaseTimelineExclusions(cal.getTime().getTime(), cal2.getTime().getTime());
                return tl;
        }
I have doubt on initnewFifteenMinuteTimeline() method, but i am not sure and also i am not getting what should i use
instead of this.
Abhay Singh

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Issue in plotting Price volumne chart

Post by skunk » Thu Jan 14, 2010 2:35 pm

Change the 40 to 36

abhay.asingh
Posts: 58
Joined: Mon Dec 15, 2008 7:07 am
Location: India
Contact:

Re: Issue in plotting Price volumne chart

Post by abhay.asingh » Fri Jan 22, 2010 1:26 pm

Hi

This works okay but caused another thing, by changing this my chart shows line
between 9 to 10 Am but now its doesn't show last one hour i.e. 3 Pm to 4 Pm..
means whole chart is shifted one hour towards morning...

can you suggest some thing else///
Abhay Singh

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Issue in plotting Price volumne chart

Post by skunk » Fri Jan 22, 2010 2:30 pm

Have a look at the second and third parameters to the SegmentedTimeline constructor

abhay.asingh
Posts: 58
Joined: Mon Dec 15, 2008 7:07 am
Location: India
Contact:

Re: Issue in plotting Price volumne chart

Post by abhay.asingh » Fri Jan 22, 2010 2:48 pm

Hi,

Thanks alot, i just forgot about include and exclude segments.
Abhay Singh

Locked