Home
Analytics
Pie chart tooltip for minimum slice
cypherdj
Hi there,
I have created a pie chart based on a data set (NAME, DESCRIPTION, VOLUME).
The category is based on row["NAME"] while the series is based on row["VOLUME"].
I've also set a minimum slice set at 2%, labelled "Others" and a mouseover tooltip for each slice displaying the DESCRIPTION, while the legend is based on NAME. This works well, except for the aggregated slice, where the tooltip shows the overall percentage of the slice (which makes sense since it cannot find a single DESCRIPTION in this case).
However, I was wondering if there was a way of displaying "Others" for the tooltip rather than the overall percentage?
Many thanks,
Cedric
Find more posts tagged with
Comments
cypherdj
I made some progress with this issue, in that I modified the expression for the tooltip to the following:
if (row["DESCRIPTION"].indexOf("%")!=-1) {
"Others";
} else {
row["DESCRIPTION"];
}
Assuming that the description would be replaced by the overall percentage, if the contents of the description contained a % then it would be the aggregated slice otherwise it's a "normal" slice. However, this did not produce the desired effect, in fact it made no difference at all!
Changing the script to label the tooltip Others if it did not contain a % in the following way:
if (row["DESCRIPTION"].indexOf("%")==-1) {
"Others";
} else {
row["DESCRIPTION"];
}
Strangely, this replaced all tooltips with Others except for the aggregated slice which still displays the overall percent for this slice.
So I'm a bit confused here, if anyone can figure out what's wrong with this script, let me know,
Regards,
Cedric
JasonW
Cedric,
Can you post your report and the BIRT Version you are using?
Jason
cypherdj
Hi Jason,
I'm using BIRT 2.2.2 and I've attached the report,
Many thanks,
Cedric
JasonW
Cedric,
Try adding the following script
function beforeDrawDataPoint(dph, fill, icsc)
{
if( dph.getBaseValue() == "Others" ){
dph.setUserValue("row["DESCRIPTION"]", "others");
}
}
and set your interactivity to just be row["DESCRIPTION"]
Jason
Example attached.
cypherdj
Nice one Jason, thanks very much!