Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
[Birt 2.6.2] Change pie chart color based on data set value
rsenden
<p>I have a data set which returns the following columns: folder_name, folder_color, count. Based on this data, I can easily create a pie chart with the folder_name as category definition, and count as Series 1. </p><p> </p><p>However, what would be the best way to set the category color based on the folder_color column returned by the data set? I have seen some examples of setting custom colors, but these all statically determine the color based on the series display value, which is not applicable in this case.</p><p> </p><p>Note that in my case, folder_color is a hexadecimal value, for example 'ff8c00'. Also note that for compatibility reasons, I am required to use BIRT 2.6.2.</p>
Find more posts tagged with
Comments
kclark
<p>Can you post some sample data and your rptdesign?</p>
rsenden
<blockquote class="ipsBlockquote" data-author="kclark" data-cid="119217" data-time="1376419981"><div><p>Can you post some sample data and your rptdesign?</p></div></blockquote><p> </p><p>Thanks for looking into this. Attached is a sample BIRT 2.6.2 rptdesign, including a scripted data set generating sample data. Categories now get a color automatically assigned by BIRT, however I would like to use the value of the FOLDER_COLOR column to set the category colors.</p><p> </p><p>Edit: updated the sample report design to include a colored table; the pie chart should use the same colors.</p><p> </p><p>BTW I just found out that the FOLDER_COLOR column can also contain CSS color names, i.e. red, blue, etcetera. Preferably the solution should work for such color definitions as well.</p>
rsenden
<p>For anyone interested in a solution for this, please see the attached piechart.rptdesign. Basically I concatenate the FOLDER_COLOR and FOLDER_NAME columns as the axis value, separated by an exclamation mark. Then I implement the beforeDrawDataPoint and beforeDrawLegendItem functions to extract the folder name and color, and set color and legend caption accordingly.</p>
prateekdwivedi2
<p>Thank You, Sir.</p><p> </p><div><p> </p><p> </p></div>
BIRT User
<p>Hi ,</p><p>Do yo know how to implement the same logic in HTML charts?.</p><p>I am not able to split the color code and column value inside HTML chart 'beforeGeneration()' method.</p>