Conditionally Color Pivot Foreground
Introduction
Conditional coloring is currently restricted to the background of the pivot cell. Use this script to switch to the foreground and optionally change the font weight to bold if desired.
Download the Pivot API as described in the post Simple Pivot API
Create your pivot table and add the following script.
widget.on('ready', function(w, args) {
var delay = 25;
setTimeout(function() {
var cArr = prism.tableGetColHeaders(element);
var numC = cArr.length;
var numR = prism.tableGetRowCount(element);
for(var r = 0; r < numR; r++) {
for(var c = 0; c < numC; c++) {
var $td = $(prism.tableGetCellTD(r, c, element));
//check see if there is a conditional color set
if($td.attr('style') && $td.attr('style').indexOf('background-color') > -1) {
//set the foreground to the background value
$td.css('color', $td.css('background-color'));
//remove the background color
$td.css('background-color', '');
//set the font weight to bold
$td.css('font-weight' , 'bold');
}
}
}
}, delay);
});
Please sign in to leave a comment.
Comments
0 comments