I have created a Gantt chart and I draw to my panel, a series of Tasks (horizontal bar lines) all with set individual durations. However, there are some tasks that will not have a duration but I still wish to show it on the panel as another horizontal line entry.
Is there any way of achieving this?
- If I set the duration to be something completely out of range, then the ChartPanel will still try and draw that task.
- If I set the duration to null, I get a NullPointerException.
Gantt Chart - Task with a Null duration.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
The NullPointerException is a bug - I've fixed it in CVS ready for the next release. Thanks for the report.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 11
- Joined: Thu Jul 07, 2005 7:40 pm
I also wanted to show singe date 'milestones', as well as lines between tasks that were dependent on each other. Here's what I did:
I modified GanttRenderer.java, Task.java, TaskSeriesCollection.java, and GanttCategoryDataset.java appropriately, and also created my own class called Milestone.java. In the drawTask method in GanttRenderer, all of the drawing is done, and in your case I think you can just add a simple if statement and then draw a oval or something to show the event.
Let me know if this helps.
I modified GanttRenderer.java, Task.java, TaskSeriesCollection.java, and GanttCategoryDataset.java appropriately, and also created my own class called Milestone.java. In the drawTask method in GanttRenderer, all of the drawing is done, and in your case I think you can just add a simple if statement and then draw a oval or something to show the event.
Let me know if this helps.
Thanks for your replies guys.
David, so with the null pointer exception fixed, does that mean that we can specify Task.setDuration(null) and this will just not draw anything on the Gantt chart? Also, would it be possible to obtain this modification? I'm working on a project which has links to an older version of the jFreechart library, and I dont want to update the .jar file because I know it would probably break stuff (and people will get annoyed with me!)
doofusLarge, if I create a derived class from the GanttRenderer, I'm not quite sure how to implement the drawTask method. Have you got any hints on how to do that, and all the parameters required for it?
Brendon.
David, so with the null pointer exception fixed, does that mean that we can specify Task.setDuration(null) and this will just not draw anything on the Gantt chart? Also, would it be possible to obtain this modification? I'm working on a project which has links to an older version of the jFreechart library, and I dont want to update the .jar file because I know it would probably break stuff (and people will get annoyed with me!)
doofusLarge, if I create a derived class from the GanttRenderer, I'm not quite sure how to implement the drawTask method. Have you got any hints on how to do that, and all the parameters required for it?
Brendon.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


I need to make the same modifications you did.doofusLARGE wrote:I also wanted to show singe date 'milestones', as well as lines between tasks that were dependent on each other. Here's what I did:
I modified GanttRenderer.java, Task.java, TaskSeriesCollection.java, and GanttCategoryDataset.java appropriately, and also created my own class called Milestone.java. In the drawTask method in GanttRenderer, all of the drawing is done, and in your case I think you can just add a simple if statement and then draw a oval or something to show the event.
Let me know if this helps.
Can you please give me more info on how to do that?