-
How to define colors in a pieChart from CDE
Hello,
it might be a basic question but I can't figure it out in CDE.
I have piechart with following values:
"Yes": 9
"No": 34
"Unknown": 23
"No Data": 4
I want the slice that corresponds to "No" to be always red, "Yes" always green etc.
I believe I cannot use the "colors" property because sometimes some of those categories might be missing so it messes up the order.
If I use the extension point pie_fillStyle, it can only be a function(d) {} where d is a value not a category that corresponds to that value.
I am sure I'm missing something basic here.
Thanks for any suggestions
Last edited by elkarel; 07-18-2012 at 12:11 PM.
-
I used the postExecution function to do this. You need to get a handle on the visible categories:
function f(){
var wedge = this.chart.pieChartPanel.pvPie;
var categories = this.chart.dataEngine.getVisibleCategories();
var ColorMap = [["Yes", "red"], ["No", "green"], ["Unknown", "orange"], ["No Data", "blue"]];
wedge.fillStyle(function() {
if(categories[this.index] == ColorMap[0][0]) {
return ColorMap[0][1];
}
else if(categories[this.index] == ColorMap[1][0]) {
return ColorMap[1][1];
}
else if(categories[this.index] == ColorMap[2][0]) {
return ColorMap[2][1];
}
else {
return ColorMap[3][1];
}
});
wedge.root.render();
}
Of course, this works well until you have many categories because of the nested if / else statements, but if you only have a few, it does the job.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules