Controlling the colors of a BIRT Pie Chart #972
ahoneycutt0929
started this conversation in
General
Replies: 3 comments
-
In this report based on the included "Classic Models" database we set the color for "Trains" to black - for the pie chart itself and for the labels. HTH |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you so much for this info.
I am pulling my data from a scripted data set and I have 3 columns, Type,
Worker, Amount. My pie series is Amount and my category is the Type field,
no grouping. I am not using a legend.
In the Type field I have values such as "Total Cash", "Total Equity" and
"Total Benefits". The pie is producing correctly for each amount value.
Using your code I am still not seeing a difference in the colors. I have
this code on the OnRender of the pie chart. I am not getting any errors.
Does anyone see anything wrong with this code? Any ideas why it would not
render?
The only difference I can see is that I am using a Scripted data set and
you are not.
function beforeDrawDataPoint(dph, fill, icsc)
{
var scriptable = icsc.getExternalContext().getScriptable();
var s=dph.getBaseDisplayValue();
if(s == "Total Cash")
{
fill.set(0, 140, 153);
} // Set to GREEN
else if(s == "Total Equity")
{
fill.set(112, 204, 0);
} // Set to Light Green
else if(s == "Total Benefits")
{
fill.set(255, 78, 0);
} // Set to Orange
else
{
fill.set(0, 0, 64);
}// Set to Blue
}
I truly appreciate any help on this.
…On Wed, May 18, 2022 at 11:54 AM Henning von Bargen < ***@***.***> wrote:
In this report based on the included "Classic Models" database we set the
color for "Trains" to black - for the pie chart itself and for the labels.
HTH
chart_dynamic_color.zip
<https://github.com/eclipse/birt/files/8717964/chart_dynamic_color.zip>
—
Reply to this email directly, view it on GitHub
<#972 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZHGGYJPEZTFJJW4BZTFDGDVKUHFFANCNFSM5WIUUD5A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I am very happy to say that I got it to work. I found a setting on the
category series that had the minimum slice set to category and 2. Removing
that and setting it to Minimum Slice Value =0 fixed the issue.
Thank you again for all your help.
…On Wed, May 18, 2022 at 11:54 AM Henning von Bargen < ***@***.***> wrote:
In this report based on the included "Classic Models" database we set the
color for "Trains" to black - for the pie chart itself and for the labels.
HTH
chart_dynamic_color.zip
<https://github.com/eclipse/birt/files/8717964/chart_dynamic_color.zip>
—
Reply to this email directly, view it on GitHub
<#972 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZHGGYJPEZTFJJW4BZTFDGDVKUHFFANCNFSM5WIUUD5A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have read several older posts on the code to control the color of each pie slice and I have tried the code of each one I found and nothing is working for me.
I do not know Java so please be nice.
I have tried using this code that I found on this forum.
function beforeDrawDataPoint( fcdph, fill, fcsc )
{
if (fcdph.getBaseDisplayValue() == "Total Cash"){
fill.set(0,140,153);
}
//else if (fcdph.getDataPointHints().getBaseDisplayValue() == "Total Equity"){
//fill.set(112,204,211);
//}
//else if (fcdph.getDataPointHints().getBaseDisplayValue() == "Total Benefits"){
//fill.set(255,78,0);
//}
else{
fill.set(255,78,0);
}
}
What should be the field listed in quotes? Nothing I have tried works.
I have my series field which is an Amount field, my Category which is a text field.
I want to control the slice colors by the different category names. I only have 3 as seen above. Is this the correct code to accomplish this? If so, what am I missing.
I have also tried using this code;
function beforeDrawDataPoint( dph, fill, icsc )
{
var stateKey = dph.getBaseDisplayValue();
if(stateKey.contains('Total Cash'))
{
fill.set(0, 140, 153);
} // Set to RED
else if(stateKey.contains('Total Equity'))
{
fill.set(112, 204, 0);
} // Set to Green
else if(stateKey.contains('Total Benefits'))
{
fill.set(255, 78, 0);
} // Set to Black
else
{
fill.set(0, 0, 64);
}// Set to Blue
}
I have loaded this code into the OnRender Script of the chart. Should it be someplace else?
Any help you can provide would be very appreciated.
I am using the most recent version of Eclipse.
I am simply want to control the colors of the slices and not have BIRT randomly pick a color from the palette.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions