cancel
Showing results for 
Search instead for 
Did you mean: 

Pivot 2.0 - Apply Conditional Formatting to Cell Text (Rather than Cell Background)

Ophir_Buchman
12 - Data Integration
12 - Data Integration

When attempting to apply conditional formatting to a Pivot 2.0 chart you might find out that you can only control a cell's background color. However, if you want to control the text color itself - Try to add this code to your Pivot widget:

 

function getWidgetDocumentObject(widget) {
if (prism.activeWidget == null)
return document.querySelector('[widgetid="' + widget.oid + '"]').querySelector('pivot2');
else
return document.querySelector('pivot2');
}

widget.on('domready', function(widget) {
try {
console.log('DOM Ready script starting (wid=' + widget.oid + ')');
doc = getWidgetDocumentObject(widget);
cells = doc.querySelectorAll('.table-grid__cell');
formatted_cells = Array.from(cells).filter(cell => cell.getAttribute('style').includes('background-color'))

formatted_cells.forEach(function(element) {
element.setAttribute('style',element.getAttribute('style').replace('background-color','color'))
});
}
catch (error) {
debugger;
console.error(error);
}
finally {
console.log('DOM Ready script complete (wid=' + widget.oid + ')');
}
});
Before After
Ophir_Buchman_1-1646678220131.png Ophir_Buchman_0-1646678196686.png

 

0 REPLIES 0