How to set Jfree GanttChart Subtasks Color and labels

我怕爱的太早我们不能终老 提交于 2019-12-02 04:11:23
trashgod

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!