开发者

How to set Jfree GanttChart Subtasks Color and labels

I am using the Jfree Charts to display Gantt Chart.I have to display differnt colors to the subtasks that are present under one series.

For Example if I have 5 tasks in series One: each task should have different color Also,I need to print 开发者_开发百科label for each task .

I tried many ways but not successful and could only set the series color alone.

Please can any one help.

Thank you.


One approach is to override getItemPaint() in your subclass of GanttRenderer. Just return a different color for each column.

Addendum:

I would need to paint the subtask depending on the task completed or not irrespective of the column value.

If I understand, you would return the completed color if that column was completed; otherwise return the non-completed color.

However, please can [you] send a code snippet.

This example should help you see the relationship between row/column and series/item.

Also, could you please let me know how to print the labels on the subtasks.

Because, a GanttRenderer is an IntervalBarRenderer, I'd look at a IntervalCategoryItemLabelGenerator.

It's not really working.

What's not working? You haven't posted any code. The example cited is a modification to the standard BarChartDemo1; it produces the following output. Note in particular how there are three series (parameter row), each having five values (parameter col). The super implementation of getItemPaint() simply returns the series paints in a cycle. Your would override that behavior to do whatever your application requires.

0 0 java.awt.GradientPaint@7e1a9d1b
1 0 java.awt.GradientPaint@540984b
2 0 java.awt.GradientPaint@53ce669e
0 1 java.awt.GradientPaint@7e1a9d1b
1 1 java.awt.GradientPaint@540984b
2 1 java.awt.GradientPaint@53ce669e
0 2 java.awt.GradientPaint@7e1a9d1b
1 2 java.awt.GradientPaint@540984b
2 2 java.awt.GradientPaint@53ce669e
0 3 java.awt.GradientPaint@7e1a9d1b
1 3 java.awt.GradientPaint@540984b
2 3 java.awt.GradientPaint@53ce669e
0 4 java.awt.GradientPaint@7e1a9d1b
1 4 java.awt.GradientPaint@540984b
2 4 java.awt.GradientPaint@53ce669e
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜