Color the Row and Value fields of a Pivot Table
widget.transformPivot(
{
type: ['value','member']
},
function setCellBackground(metadata, cell) {
if(metadata.type == 'value'){
cell.style = cell.style || {};
cell.style.backgroundColor = '#9A94BC';
} else {
cell.style = cell.style || {};
cell.style.backgroundColor = '#ffe6e6';
}
}
);
3. Change the colors by changing the color codes above and you're all set!
Note: If you'd like to target different parts of the pivot table, refer to our Pivot 2 API documentation.
1 comment
harish
·2 years agoHii, I have pivot table merchant names and sales , now i want to color the top 3 and bottom 3 of sales column , top 3 should be green and bottom 3 should be red . How can i achieve that