如何设置Jfree GanttChart子任务的颜色和标签 [英] How to set Jfree GanttChart Subtasks Color and labels

查看:109
本文介绍了如何设置Jfree GanttChart子任务的颜色和标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jfree图表显示甘特图.我必须为一系列显示的子任务显示不同的颜色.

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.

例如,如果我有5个任务系列一:每个任务应具有不同的颜色 另外,我需要为每个任务打印标签.

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.

请帮忙.

谢谢.

推荐答案

一种方法是覆盖

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

附录:

无论列值如何,我都需要根据完成的任务或不完成的任务来绘制子任务.

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.

因为GanttRendererIntervalBarRenderer,所以我看一下

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

这篇关于如何设置Jfree GanttChart子任务的颜色和标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆