I am drawing a Gantt Chart using JFreeChart. The following is the data that I am fetching from the database:
ACTID NAME PLNSTRTDATE PLNENDDATE ACTSTRTDATE ACTENDDATE
5 Approve PMP 5/1/2006 6/30/2006 5/1/2006 5/1/2006
140 Check in/Check out 5/1/2006 6/30/2006 5/1/2006 5/1/2006
139 Doc Preparation 5/1/2006 6/30/2006 5/1/2006 5/1/2006
103 HW/SW 5/1/2006 6/30/2006 5/1/2006 5/1/2006
6 Baseline PMP 6/1/2006 6/21/2006 6/1/2006 6/1/2006
1 Project Kick off 6/6/2006 6/28/2006 6/6/2006 6/6/2006
8 Project Doc Prep 6/7/2006 7/31/2006 6/1/2006 6/26/2006
105 Review Prj Est 6/12/2006 6/16/2006 6/12/2006 6/12/2006
140 Check in/Check out 6/20/2006 6/29/2006 6/20/2006 6/20/2006
The following is the code that I use to generate the Gantt:
Code: Select all
IntervalCategoryDataset intervalcategorydataset;
Iterator iter = ganttchart.listIterator();
TaskSeries scheduled = new TaskSeries("Scheduled");
TaskSeries actual = new TaskSeries("Actual");
TaskSeriesCollection taskseriescollection = new TaskSeriesCollection();
while (iter.hasNext())
{
prjVO = (ProjectVO)iter.next();
scheduled.add(new Task(prjVO.getName(),prjVO.getPSdate(),prjVO.getPEdate()));
actual.add(new Task(prjVO.getName(),prjVO.getASdate(),prjVO.getAEdate()));
}
taskseriescollection.add(scheduled);
taskseriescollection.add(actual);
intervalcategorydataset=taskseriescollection;
JFreeChart jfreechart = ChartFactory.createGanttChart("Gantt Chart", "Task", "Date", intervalcategorydataset, true, true, false);
CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
//categoryplot.getDomainAxis().setCategoryMargin(10);
GanttRenderer renderer = (GanttRenderer)categoryplot.getRenderer(0);
renderer.setMaxBarWidth(0.05);
renderer.setItemMargin(0.1);
renderer.setSeriesPaint(0, Color.green);
//categoryplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10F);
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(jfreechart, 1000, height, info, session);
session.setAttribute("aim/filename",filename);
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
The following is the query that I use to fetch the records:
Code: Select all
select distinct a.Activity_id, b.Name, a.plan_start_date, a.plan_end_date,
NVL(a.act_start_date, a.plan_start_date) ACT_START_DATE,
NVL(a.act_end_date, NVL(a.act_start_date,a.plan_start_date)) ACT_END_DATE
from Taim_Allocated_task a, Taim_Activity b
where a.task_id in
(select task_id from taim_task
where Project_id='TD0001'
and company_id='794')
and a.company_id='794'
and b.Company_id = a.company_id
and b.activity_id= a.activity_id
and a.status='Y'
order by a.plan_start_date
Please do reply to this post ASAP as we have to move our code into production by Wednesday, 5th July 2006.