Regarding Gantt chart generation

Ads

 
 

Share on Google+Share on Google+

amrutha
Regarding Gantt chart generation
3 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

May 16, 2009 at 3:59 PM


Hi Friend,

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))));


May 16, 2009 at 4:00 PM


continue..........

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);
}
}

Thanks


March 17, 2011 at 4:55 AM


How I can embed the Ganttchart on JSP page ???


Ads









Related Tutorials/Questions & Answers:
Regarding Gantt chart generation - Java Beginners
Regarding Gantt chart generation  how to generate a jdbc gantt chart..., To create a simple Gantt chart, try the following code: import...; JFreeChart chart = ChartFactory.createGanttChart( "Gantt Chart
regarding bill generation - JSP-Servlet
regarding bill generation  in this program it is connected with database in mysql.when a customer or user enters he can able to see his payable amount as well as what he paid before as bill
Advertisements
gantt charts - Swing AWT
gantt charts  Hello, i am doing project on project management tool there i need to generate a gantt chart for daily activity done by developer regarding how many hours they have spent for each activity. If the database contains
gantt charts - Java Beginners
gantt charts  Actually while generating the gantt chart it has...( "Gantt Chart Example", "Task", "Date...)); ChartFrame frame=new ChartFrame("Gantt Chart",chart); frame.setVisible
pdf generation.
pdf generation.  i want to generate the data which is stored in mysql data base in pdf format with php. how i will do
report generation
report generation  hi i found some source codes related to barchart and pie chart .when i try to run thise code its showing me the error as :- java.lang.NoSuchMethodError: org.jfree.text.TextBlock.setLineAlignment(Lorg/jfree/ui
Barcode generation
Barcode generation  hi, I am working on a project where there is a alias no. with symbology EAN-13 for generation of barcode... now i have to write the logic for one item no if their are two or more quantities it should
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi, I successfully executed the bar chart in normal java application. But I want the Bar Chart to be executed...-jsppage.shtml http://www.roseindia.net/jsp/draw-statistical-chart-jsp.shtml
jfree chart
jfree chart  i need donut chart using jfree
pie chart
pie chart  how to create pie chart using struts2
Pie chart
Pie chart  hi................. In my project i want to create a pie-chart by taking values at run time. As want to display it in pie chart form....   Java Swing PIE Chart
report generation using jsp
report generation using jsp  report generation coding using jsp
bar chart
bar chart  how to create a bar chart from values of the database and the string value should be the entities of the database??plzz help..needed badly
regarding rev
regarding rev  write a prog. in java that display all the arguments passed at the command line in reverse order
Regarding repository
Regarding repository  How to check in and check out using SVN repository using eclipse
Regarding Hibernate
Regarding Hibernate  Both JDBC and Hibernate are used to connect to database then whats the need of going to hibernate? What are the main differences? And could you let me know please
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
report generation - EJB
report generation   how to create the report in java
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi in the http://www.roseindia.net/chartgraphs/barchart-jsppage.shtml of the code (new StandardEntityCollection..."); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception e
Regarding javascript
Regarding javascript  Hi, I want 4 upload buttons in HTML CODE and Among 4 browse buttons user is not selected any one then provide a prompt message like plz select any 1 file among 4 buttons.If user is selected either 1st
PDF Generation for unicode characters
PDF Generation for unicode characters  Hi, How a PDF file having unicode characters is generated in JSP
Regarding Datasource
Regarding Datasource  Hi friend, Good morning,how r u,i want to share 1 information to u,I got a job in VERIZON DATA SERVICES INDIA PVT.LTD,u help a lot when i am in academic project,with that project only i got a job
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container below that row itself and show the required details of the row
regarding project
regarding project  OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client requirement. -Ability of the programmer to ask the right questions and get the relevant
regarding project
regarding project  OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client requirement. -Ability of the programmer to ask the right questions and get
jaret timebars
containing rows of intervals. The viewer displays the intervals in a Gantt chart... (classic gantt) and vertical orientation addon package supports using
regarding project
regarding project   sir we need help about project. we have idea about his project please guide me sir. OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client
barchart generation - Java Beginners
barchart generation  Please suggest me how to generate the bar chart for this type of query. JDBCCategoryDataset dataset=new JDBCCategoryDataset(co,"SELECT rsa,rors,dda from activity where pcode=? and taskname=? and date
Chart & Graphs Tutorials in Java
Chart & Graphs Tutorials in Java  ... in Java. Our Chart and Graphs tutorials will help learn everything you need to learn about chart and graphs programming in Java. We have provided many examples
draw chart in web application
draw chart in web application  how to draw bar chat from the record store in database? i.e. draw the bar chart according to selected record