cancel
Showing results for 
Search instead for 
Did you mean: 

Pivot 2.0 - Add Conditional Formatting to the Sub/Grand-Total Rows

Ophir_Buchman
12 - Data Integration
12 - Data Integration

When attempting to apply formatting to a Pivot 2.0 chart you might find out that it doesn't apply to the Sub-Total and Grand-Total rows. The following (widget) code applies conditional formatting to negative numbers:

 

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 = Array.from($('.table-grid__cell--row-user-type-grandTotal, .table-grid__cell--row-user-type-subTotal'))
cells.forEach(function(element) {
if(element.innerText.startsWith('-'))
element.lastChild.setAttribute('style','color:red')
})
});
}
catch (error) {
debugger;
console.error(error);
}
finally {
console.log('DOM Ready script complete (wid=' + widget.oid + ')');
}
});
Before After
Ophir_Buchman_3-1646828870288.png Ophir_Buchman_2-1646828811818.png

 

1 REPLY 1

jamesm
7 - Data Storage
7 - Data Storage

Is this possible to do without scripting?