java - Why isn't the correct data appears in the gant chart? -



java - Why isn't the correct data appears in the gant chart? -

hi how ?

i made ​​a java application manage tasks, , intend create gant charts of subtasks.

i did following, info not appear correctly.

as can see image posted, although appear 3 bars appear info single subtask. nil appears on left. not know why happens.

does can help me solve little problem please?

result of query:

subtask startdate enddate t3.1 2014-04-29 2014-06-05 t3.2 2014-06-05 2014-06-05 t3.3 2014-06-09 2014-06-09

code

public class gantdemo { private static date date(int day, int month, int year) { calendar calendar = calendar.getinstance(); calendar.set(year, month, day); date result = calendar.gettime(); homecoming result; } public static void main(string[] args) { connection con = null; taskseriescollection collection = new taskseriescollection(); /* mysql */ string databaseurl = "jdbc:mysql://localhost:3306/tasks1.5"; string drivername = "com.mysql.jdbc.driver"; string user = "****"; string password = "*****"; seek { class.forname(drivername).newinstance(); } grab (exception ex) { system.out.println(""); } seek { con = drivermanager.getconnection(databaseurl, user, password); if (!con.isclosed()) { system.out.println("successfully connected database server..."); } statement statement; statement = con.createstatement(); string selectquery = "select idsubtask, startdate, enddate tasks idtask 't3' "; resultset resultset = null; resultset = statement.executequery(selectquery); if (resultset != null) // success { while (resultset.next()) { string idsubtask = (string) resultset.getobject("idsubtask "); string startdate= (string) resultset.getobject("startdate"); string enddate = (string) resultset.getobject("enddate "); simpledateformat sdf2 = new simpledateformat("yyyy-mm-dd"); date dates = sdf2.parse(datainicio); simpledateformat sdf3 = new simpledateformat("yyyy-mm-dd"); date datef = sdf3.parse(datafim); //delete system.out.println("" + idsubtask + " " + startdate+ " " + enddate ); taskseries schedule1 = new taskseries("scheduled tasks"); schedule1.add(new task(idsubtask, new simpletimeperiod(dates, datee))); collection.add(schedule1); } } resultset.close(); } grab (exception e) { system.out.println("" + e); } intervalcategorydataset dataset = collection; jfreechart chart = chartfactory.createganttchart( "gantt chart example", // chart heading "subtask", // 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); } }

you're overriding taskseries every iteration. add together taskseries object collection once.

example:

public class gantdemo { public static void main(string[] args) throws parseexception { taskseriescollection collection = new taskseriescollection(); list<subtask> list = new arraylist<subtask>(); list.add(new subtask("t3.1", "2014-04-29", "2014-06-05")); list.add(new subtask("t3.2", "2014-06-05", "2014-06-15")); list.add(new subtask("t3.3", "2014-06-09", "2014-06-19")); taskseries schedule1 = new taskseries("scheduled tasks"); (subtask task : list) { date dates = new simpledateformat("yyyy-mm-dd") .parse(task.startdate); date datee = new simpledateformat("yyyy-mm-dd").parse(task.enddate); schedule1.add(new task(task.taskid, new simpletimeperiod(dates, datee))); } collection.add(schedule1); system.out.println(collection.tostring()); intervalcategorydataset dataset = collection; jfreechart chart = chartfactory.createganttchart("gantt chart example", "subtask", // 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); } private static class subtask { private string taskid; private string startdate; private string enddate; public subtask(string taskid, string startdate, string enddate) { super(); this.taskid = taskid; this.startdate = startdate; this.enddate = enddate; } } }

another thing dates covered charts won't plot( subtask 2 , 3)

java jfreechart

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -