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)
Pie Chart with Minimum Slice causes problem with Color Assignment
kkapera
When using a pie chart with a minimum slice defined, the colors assigned from the series palette are no longer ordered as they appear in the palette. This then gives me no control over the final appearance of the chart. It seems that the deleted or consolidated slices still retain their original numbering and act as "placeholders" so that the colors of the remaining slices are shifted in the palette. In this way I can get adjacent slices with the same color for example.
I filed a bug report but thought I would try in the forum.
I am running the 2.5.1 RCP version of the designer.
This happens both in preview mode and web viewer.
Any thoughts?
Find more posts tagged with
Comments
mwilliams
Hi kkapera,
Definitely sounds like a bug. If you had an array of defined colors, you could possibly step through the slices and assign your own colors in the plot and in the legend. I have not attempted this yet, so I don't know if the "minimum slice" values would still be stepped through here as well.
Could you post the bug info on this in here for future reference? Thanks.
kkapera
Michael,
The bug number is: 302857. I have not received a reply as yet.
I did write an onRender script (event beforeDrawDataPoint) hard-coding the RGB values from ther series palette and it does not correct the problem.
I also tried all formats (SVG, etc) and it fails for each.
mwilliams
What happens when you try to manually enter colors? The same thing?
kkapera
It does assign the colors that I tell it just fine when not enabling the minimum slice. I think the issue this:
Suppose series palette has
Color 1 Blue
Color 2 Red
Color 3 Green
And data series has
Values
1 - 199
2 -99
3 - 299
And minimum slice defined as < 100
Point 1 is drawn with color 1
Point 2 is consolidated into min slice
Point 3 is drawn not with color 2 but with color 3. The eliminated slice because it still has a slice # (array index) causes a shift in the colors used so you can't tell what colors will be adjacent to each other.
That's my theory anyway.
mwilliams
Yes, I agree that that's what is happening with the series palette. Is that the same issue you're having when you try to iterate through a list of your own color definitions, manually assigning the colors in script?
Thanks for the bug info, btw.
kkapera
Yes same problem. Here is script:
/**
* Called before drawing each datapoint graphical representation or marker.
*
*
@param
dph
* DataPointHints
*
@param
fill
* Fill
*
@param
icsc
* IChartScriptContext
*/
function beforeDrawDataPoint( dph, fill, icsc )
{
var wedgenum2=dph.getIndex()%10;
var wedgenum=dph.getIndex();
/*
switch (wedgenum2)
{
case 0:
fill.set(80,166,218);
break;
case 1:
fill.set(242,88,106);
break;
case 2:
fill.set(232,172,57);
break;
case 3:
fill.set(128,255,128);
break;
case 4:
fill.set(64,128,128);
break;
case 5:
fill.set(128,128,192);
break;
case 6:
fill.set(170,85,85);
break;
case 7:
fill.set(128,128,0);
break;
case 8:
fill.set(192,192,192);
break;
case 9:
fill.set(255,255,128);
break;
}
*/
//if( dph.getBaseValue() == "Others" ){
//dph.setUserValue("row["CUSTOMERNUMBER"]", "others");
//}
dph.setUserValue("row["CUSTOMERNUMBER"]", " slice "+wedgenum);
}
kkapera
code is commented out in the above example..... but have run it enabled... fyi..
mwilliams
One thing you could do, since you can grab the data value is to iterate your own variable in each case and do a check on the data value before going into the case statement. If the value is included in your minimum slice, you wouldn't use a color from your list and you wouldn't increment your variable.
kkapera
that was a thought. Just fairly new to BIRT scripting and getting/setting persistent globals (which I assume would be the method)
mwilliams
kkapera,<br />
<br />
You could do it in the chart with something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
i=0;
function beforeDrawDataPoint( dph, fill, icsc )
{
if (dph.getOrthogonalValue() != 0){
switch (i)
{
case 0:
fill.set(255,0,0);
i++;
break;
case 1:
fill.set(0,255,0);
i++;
break;
case 2:
fill.set(0,0,255);
i++;
break;
case 3:
fill.set(0,0,0);
i++;
break;
case 4:
fill.set(255,255,255);
i++;
break;
case 5:
fill.set(255,255,0);
i++;
break;
case 6:
fill.set(255,0,255);
i++;
break;
case 7:
fill.set(128,128,0);
i++;
break;
case 8:
fill.set(192,192,192);
i++;
break;
case 9:
fill.set(255,255,128);
i++;
break;
}
}
}
</pre>
<br />
You would also have to make the same changes to the color in your legend.<br />
<br />
Let me know if you have questions.