Different colors for each subtasks in Gantt chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
moonblade
Posts: 21
Joined: Mon Sep 18, 2006 9:41 am

Different colors for each subtasks in Gantt chart

Post by moonblade » Thu Sep 21, 2006 11:12 am

Dear all,

As i understand, to set a different color for different series is using this :

Code: Select all

CategoryItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(0, Color.blue);
Is there a way to set different colors for each subtask in the same series ?

Please advise .. :D

moonblade
Posts: 21
Joined: Mon Sep 18, 2006 9:41 am

Post by moonblade » Fri Sep 22, 2006 3:04 am

Please help ..

Is there any method for this purpose, or do i have to create my own renderer or maybe something else ?

moonblade
Posts: 21
Joined: Mon Sep 18, 2006 9:41 am

Post by moonblade » Fri Sep 22, 2006 9:32 am

I'm pasting the source code, it's already available in the demo GanttDemo2.java.
The sub tasks example is in the Design Phase, they are all in blue base color. There are 3 subtasks, and i want to have 3 colors for each subtasks. Do i have to provide my own implementation of the renderer class, and if it is so, which method should i play with ? Please help

Code: Select all

/* ---------------
 * GanttDemo2.java
 * ---------------
 * (C) Copyright 2003-2005, by Object Refinery Limited.
 *
 */

REMOVED

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Sep 22, 2006 10:01 am

moonblade wrote:I'm pasting the source code, it's already available in the demo GanttDemo2.java.
The demo source code is available to download when you purchase the JFreeChart Developer Guide. You are not permitted to redistribute the demo code, so please don't post it in the forum or anywhere else.
moonblade wrote:Do i have to provide my own implementation of the renderer class, and if it is so, which method should i play with ? Please help
Yes, you'll need to modify the renderer. Start by looking in the drawTasks() method. All renderers inherit the ability to set the paint "per item", but in this case the sub-tasks are "sub items"...so you'll need your own data structures to specify the different colors per sub item.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

moonblade
Posts: 21
Joined: Mon Sep 18, 2006 9:41 am

Post by moonblade » Mon Sep 25, 2006 3:40 am

I'm so sorry, i didnt know :oops:
Thanks for your guide, i'll look into it asap

Locked