Issue in assigning unique colors for each common segment

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
m.hammadpk
Posts: 3
Joined: Thu May 04, 2017 9:40 pm
antibot: No, of course not.

Issue in assigning unique colors for each common segment

Post by m.hammadpk » Thu May 04, 2017 9:57 pm

Hi all,

I want to create Stacked Bar Chart using jfreechart. I have following type of data:

DID (Unqiue Id)
SID (Unqiue Id-In each SID, there are lot of unique DIDs)
Height (Integer number which determines the height of each DID)
CID (Contains list of common DID across SID. So, there is a need to assign common color patterns for DID across SID)

So, in short, this stackedbarchart will provide a view of common "DID"s across "SID".


The issue that I am facing is how can I tell the system to use unique color patterns for the list of common DID across SID.

Please guide me. I will be thankful to you.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Issue in assigning unique colors for each common segment

Post by John Matthews » Fri May 05, 2017 4:44 am

I don't understand the pattern you want to achieve, but this example override's the renderer's getItemPaint() method to print out the row, column and default color for each item. You can examine the dataset entry corresponding to each row and column to decide what color to return.

m.hammadpk
Posts: 3
Joined: Thu May 04, 2017 9:40 pm
antibot: No, of course not.

Re: Issue in assigning unique colors for each common segment

Post by m.hammadpk » Sat May 06, 2017 8:56 am

Hi John,

Thanks for your reply. I am a novice user in using Jfreecharts, that's why I am struggling in creating stack bar chart of desired values.

I am attaching "Table values" and demo of "Stack bar chart".

I am assigning values like

Code: Select all

dataset.addValue(DID, CID,SID);
Here, I cannot be able to use the variable "Height", which I would like.

In the attached image of "Stack bar chart", I have mentioned what desired result would I like by using annotations.

Please assist me how can I use all the combinations of four values (SID, DID, CID, Height) in creating a desired stack bar chart?


It will be really great, if you can post some sample code of that. I will be extremely thankful to you.


https://drive.google.com/file/d/0B2YaKt ... sp=sharing

https://drive.google.com/file/d/0B2YaKt ... sp=sharing

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Issue in assigning unique colors for each common segment

Post by John Matthews » Mon May 08, 2017 2:37 am

I'm not sure where you're stuck; for reference, I found complete examples here and here.

m.hammadpk
Posts: 3
Joined: Thu May 04, 2017 9:40 pm
antibot: No, of course not.

Re: Issue in assigning unique colors for each common segment

Post by m.hammadpk » Mon May 08, 2017 11:26 am

Thanks John for your reply, I have successfully resolved the issue.

Locked