
How I can embed ganttChart on JSP page ??? Im already created ganttChart by using this example:
To create a simple Gantt chart, try the following code:
import java.awt.Color; import java.util.Date; import java.util.Calendar; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import org.jfree.chart.ChartFactory; import org.jfree.chart.*; import org.jfree.chart.JFreeChart; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; import org.jfree.data.gantt.TaskSeriesCollection; import org.jfree.data.time.SimpleTimePeriod;
public class GanttChartExample { private static Date date( int day, int month, int year) {
Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); Date result = calendar.getTime(); return result; } public static void main( String[] args) {
TaskSeries schedule1 = new TaskSeries("Scheduled Tasks"); schedule1.add(new Task("Feasibility Study", new SimpleTimePeriod(date(1, Calendar.JANUARY, 2008), date(10, Calendar.JANUARY, 2008)))); schedule1.add(new Task("Requirement Analysis", new SimpleTimePeriod(date(11, Calendar.JANUARY, 2008), date(21, Calendar.JANUARY, 2008)))); schedule1.add(new Task("Designing", new SimpleTimePeriod(date(22, Calendar.FEBRUARY, 2008), date(21, Calendar.MARCH, 2008)))); schedule1.add(new Task("Coding", new SimpleTimePeriod(date(22, Calendar.MARCH, 2008), date(30, Calendar.MAY, 2008)))); schedule1.add(new Task("Testing", new SimpleTimePeriod(date(2, Calendar.JUNE, 2008), date(18, Calendar.JUNE, 2008)))); schedule1.add(new Task("Implementation", new SimpleTimePeriod(date(19, Calendar.JUNE, 2008), date(31, Calendar.JULY, 2008)))); schedule1.add(new Task("Post Implementation", new SimpleTimePeriod(date(1, Calendar.AUGUST, 2008), date(1, Calendar.NOVEMBER, 2008))));
TaskSeries schedule2 = new TaskSeries("Actual Done"); schedule2.add(new Task("Feasibility Study", new SimpleTimePeriod(date(1, Calendar.JANUARY, 2008), date(15, Calendar.JANUARY, 2008)))); schedule2.add(new Task("Requirement Analysis", new SimpleTimePeriod(date(16, Calendar.JANUARY, 2008), date(29, Calendar.JANUARY, 2008)))); schedule2.add(new Task("Designing", new SimpleTimePeriod(date(22, Calendar.FEBRUARY, 2008), date(30, Calendar.MARCH, 2008)))); schedule2.add(new Task("Coding", new SimpleTimePeriod(date(1, Calendar.APRIL, 2008), date(20, Calendar.JUNE, 2008)))); schedule2.add(new Task("Testing", new SimpleTimePeriod(date(21, Calendar.JUNE, 2008), date(8, Calendar.JULY, 2008)))); schedule2.add(new Task("Implementation", new SimpleTimePeriod(date(9, Calendar.JULY, 2008), date(23, Calendar.AUGUST, 2008)))); schedule2.add(new Task("Post Implementation", new SimpleTimePeriod(date(1, Calendar.SEPTEMBER, 2008), date(10, Calendar.DECEMBER, 2008))));
TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(schedule1); collection.add(schedule2); IntervalCategoryDataset dataset= collection;
JFreeChart chart = ChartFactory.createGanttChart( "Gantt Chart Example", // chart Heading "Task", // X-axis label "Date", // Y-axis label dataset, // dataset true, // legend true, // tooltips false // urls ); chart.setBackgroundPaint(new Color(0xff,0xff,0xcc)); ChartFrame frame=new ChartFrame("Gantt Chart",chart); frame.setVisible(true); frame.setSize(400,350); } }
Any idea ??
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.