gantt charts

gantt charts

View Answers

May 18, 2009 at 1:38 PM

Hi Friend,

Take 3 fields in your database table, task,date1,date2 whose data types are varchar, date and date respectively.

Now 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;
import java.sql.*;

public class GanttChartExample {

public static void main( String[] args) {
JFreeChart chart=null ;
TaskSeries schedule1 = new TaskSeries("Scheduled Tasks");
TaskSeries schedule2 = new TaskSeries("Actual Done");
Connection con = null;
String url = "jdbc:mysql://192.168.10.112:3306/";;
String db = "mysql";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM chart");
while (rs.next()) {
schedule1.add(new Task(rs.getString(1), new SimpleTimePeriod((rs.getDate(2)),(rs.getDate(3)))));

schedule2.add(new Task(rs.getString(1), new SimpleTimePeriod((rs.getDate(2)), (rs.getDate(2)))));
TaskSeriesCollection collection = new TaskSeriesCollection();
collection.add(schedule1);
collection.add(schedule2);
IntervalCategoryDataset dataset= collection;

chart = ChartFactory.createGanttChart(
"Gantt Chart Example",
"Task",
"Date",
dataset,
true,
true,
false
);
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
chart.setBackgroundPaint(new Color(0xff,0xff,0xcc));
ChartFrame frame=new ChartFrame("Gantt Chart",chart);
frame.setVisible(true);
frame.setSize(400,350);
}
}
Thanks









Related Tutorials/Questions & Answers:
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
Advertisements
ModuleNotFoundError: No module named 'gantt'
ModuleNotFoundError: No module named 'gantt'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'gantt' How to remove the ModuleNotFoundError: No module named 'gantt'
ModuleNotFoundError: No module named 'gantt'
ModuleNotFoundError: No module named 'gantt'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'gantt' How to remove the ModuleNotFoundError: No module named 'gantt'
ModuleNotFoundError: No module named 'minimal-gantt'
ModuleNotFoundError: No module named 'minimal-gantt'  Hi, My... 'minimal-gantt' How to remove the ModuleNotFoundError: No module named 'minimal-gantt' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'minimal-gantt'
ModuleNotFoundError: No module named 'minimal-gantt'  Hi, My... 'minimal-gantt' How to remove the ModuleNotFoundError: No module named 'minimal-gantt' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pyexcel-gantt'
ModuleNotFoundError: No module named 'pyexcel-gantt'  Hi, My... 'pyexcel-gantt' How to remove the ModuleNotFoundError: No module named 'pyexcel-gantt' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-gantt'
ModuleNotFoundError: No module named 'python-gantt'  Hi, My Python... 'python-gantt' How to remove the ModuleNotFoundError: No module named 'python-gantt' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'integer-gantt'
ModuleNotFoundError: No module named 'integer-gantt'  Hi, My... 'integer-gantt' How to remove the ModuleNotFoundError: No module named 'integer-gantt' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'openerp-web-gantt'
ModuleNotFoundError: No module named 'openerp-web-gantt'  Hi, My... named 'openerp-web-gantt' How to remove the ModuleNotFoundError: No module named 'openerp-web-gantt' error? Thanks   Hi, In your
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
flow charts
flow charts   draw a flow chart program with a user prompt of 5 numbers computing the maximum, minimum and average
jree charts
jree charts  i have to use jfree charts how to download its api and where to keep it in jdk order to execute   Please visit the following link: Download JFreechart Download jfreechart-1.0.13.zip from the given link
ModuleNotFoundError: No module named 'charts'
ModuleNotFoundError: No module named 'charts'  Hi, My Python... 'charts' How to remove the ModuleNotFoundError: No module named 'charts'... to install padas library. You can install charts python with following command
How to create charts in Java?
How to create charts in Java?  Is there any example of creating charts and graphs in Java? thanks   Hi, check the tutorial: Chart & Graphs Tutorials in Java Thanks
java charts - Development process
java charts  Hi,i want to create charts wrt database by using jsp?please help me
generate charts using JSP
generate charts using JSP  any one know coding for generate bar chart or pie chart using JSP
Doubt Regarding Charts
Doubt Regarding Charts  Hi, Can you please help me out by answering "hoe to include charts in core java code and struts code" thanks in advance... charts and graphs
java bar charts and jsp
java bar charts and jsp  Hi, Can any one help me out in how to create java bar charts using jsp with the help of data base table values? thanks in advance   Have a look at the given link: http://www.roseindia.net
java charts - JSP-Servlet
java charts  Hi,can any one tell me how to create dyanamic charts wrt database contents by using jsp-servlet
Bar charts and jsp
Bar charts and jsp  Hi, How to generate Dynamic Bar Chart Images using jsp with placing any image location in weebroots? Thanks in advance
Version of com.ahome-it>lienzo-charts dependency
List of Version of com.ahome-it>lienzo-charts dependency
Merge XYLine and XYArea Charts
Merge XYLine and XYArea Charts  I wonder how to merge two charts... (this website) how to use two XYLine Charts and display them. Please, see screenshot... appreciate any help. Please, bear in mind I am new to charts plotting in java
ModuleNotFoundError: No module named 'agate-charts'
ModuleNotFoundError: No module named 'agate-charts'  Hi, My Python... 'agate-charts' How to remove the ModuleNotFoundError: No module named 'agate-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangocms-charts'
ModuleNotFoundError: No module named 'djangocms-charts'  Hi, My... named 'djangocms-charts' How to remove the ModuleNotFoundError: No module named 'djangocms-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'plotly-charts'
ModuleNotFoundError: No module named 'plotly-charts'  Hi, My... 'plotly-charts' How to remove the ModuleNotFoundError: No module named 'plotly-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pudzu-charts'
ModuleNotFoundError: No module named 'pudzu-charts'  Hi, My Python... 'pudzu-charts' How to remove the ModuleNotFoundError: No module named 'pudzu-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'agate-charts'
ModuleNotFoundError: No module named 'agate-charts'  Hi, My Python... 'agate-charts' How to remove the ModuleNotFoundError: No module named 'agate-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangocms-charts'
ModuleNotFoundError: No module named 'djangocms-charts'  Hi, My... named 'djangocms-charts' How to remove the ModuleNotFoundError: No module named 'djangocms-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Flask-Charts'
ModuleNotFoundError: No module named 'Flask-Charts'  Hi, My Python... 'Flask-Charts' How to remove the ModuleNotFoundError: No module named 'Flask-Charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'helm-charts'
ModuleNotFoundError: No module named 'helm-charts'  Hi, My Python... 'helm-charts' How to remove the ModuleNotFoundError: No module named 'helm-charts' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'plotly-charts'
ModuleNotFoundError: No module named 'plotly-charts'  Hi, My... 'plotly-charts' How to remove the ModuleNotFoundError: No module named 'plotly-charts' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-charts'
ModuleNotFoundError: No module named 'django-charts'  Hi, My... 'django-charts' How to remove the ModuleNotFoundError: No module named 'django-charts' error? Thanks   Hi, In your python
Good Looking Java Charts and Graphs
Good Looking Java Charts and Graphs  Is there a java chart library that will generate charts and graphs with the quality of visifire or fusion charts? The JFreeChart graph quality is not professional looking. Unless it can
Charts in JSP - JSP-Servlet
Charts in JSP  Hi Roseindia team, This is ragav.. I am currently in a project where i must display the database results in terms of charts in JSP.. So, Can i know the pre requirement for that? Do i need
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 in web application(jsp). So,please help me out in how to connect the normal
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()); final File file1 = new File("../webapps/jspchart/web/barchart.png
Charts in JSP - JSP-Servlet
Charts in JSP  Hi, Thanks for replying for the chart query I made 2 days back.. Can u plz provide me an example for creating a series bar chart with the datas coming from the database? Series chart in the sense, If I have x
Statistical charts in JSP - problem
Statistical charts in JSP - problem  hey! i get this error when i run the code (with slight changes in query)! HTTP Status 500 - type Exception report (adsbygoogle = window.adsbygoogle || []).push
ModuleNotFoundError: No module named 'django-admin-charts'
ModuleNotFoundError: No module named 'django-admin-charts'  Hi, My... named 'django-admin-charts' How to remove the ModuleNotFoundError: No module named 'django-admin-charts' error? Thanks   Hi
ModuleNotFoundError: No module named 'salt-finder-charts'
ModuleNotFoundError: No module named 'salt-finder-charts'  Hi, My... named 'salt-finder-charts' How to remove the ModuleNotFoundError: No module named 'salt-finder-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'soundcloud-charts-api'
ModuleNotFoundError: No module named 'soundcloud-charts-api'  Hi...: No module named 'soundcloud-charts-api' How to remove the ModuleNotFoundError: No module named 'soundcloud-charts-api' error? Thanks   Hi
ModuleNotFoundError: No module named 'acdh-django-charts'
ModuleNotFoundError: No module named 'acdh-django-charts'  Hi, My... named 'acdh-django-charts' How to remove the ModuleNotFoundError: No module named 'acdh-django-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'CanvasJS-Django-Charts'
ModuleNotFoundError: No module named 'CanvasJS-Django-Charts'  Hi...: No module named 'CanvasJS-Django-Charts' How to remove the ModuleNotFoundError: No module named 'CanvasJS-Django-Charts' error? Thanks   Hi
ModuleNotFoundError: No module named 'dash-google-charts'
ModuleNotFoundError: No module named 'dash-google-charts'  Hi, My... named 'dash-google-charts' How to remove the ModuleNotFoundError: No module named 'dash-google-charts' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-admin-charts'
ModuleNotFoundError: No module named 'django-admin-charts'  Hi, My... named 'django-admin-charts' How to remove the ModuleNotFoundError: No module named 'django-admin-charts' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-google-charts'
ModuleNotFoundError: No module named 'django-google-charts'  Hi...: No module named 'django-google-charts' How to remove the ModuleNotFoundError: No module named 'django-google-charts' error? Thanks   Hi
ModuleNotFoundError: No module named 'enaml-native-charts'
ModuleNotFoundError: No module named 'enaml-native-charts'  Hi, My... named 'enaml-native-charts' How to remove the ModuleNotFoundError: No module named 'enaml-native-charts' error? Thanks   Hi
ModuleNotFoundError: No module named 'gnuhealth-pediatrics-growth-charts'
ModuleNotFoundError: No module named 'gnuhealth-pediatrics-growth-charts' ...: ModuleNotFoundError: No module named 'gnuhealth-pediatrics-growth-charts' How to remove the ModuleNotFoundError: No module named 'gnuhealth-pediatrics-growth-charts
Introduction to Graphs and Charts
Introduction to Graphs and Charts       Why Charts and Graphs?  Graphs and Charts is the most efficient method for displaying information in a simple manner

Ads