Forum Discussion
gds
02-13-2024Data Storage
This code gets me what I need, but I don't believe it is the most efficient manner, as I had to manually exclude certain titles from appearing. Any suggestions would be helpful. Thank you!
To learn how you can access the Widget and Dashboard objects, see the online documentation at https://sisense.dev/guides/js/extensions
*/
widget.transformPivot({ type: ['value'] }, function(metadata, cellData) {
if(metadata.measure.title === "Days Since Last Version" ){
if(cellData.value > '31'){
cellData.style.backgroundColor = '#ff9c8a';
}
else if (cellData.value <= '31'){
cellData.style.backgroundColor = '#b1ffae';
}
}
if (metadata.measure.title === "Current Version" && metadata.measure.title("Current Version").cellData.value % 1 !=0){
cellData.style.backgroundColor = '#fffcae';
}
});
var columns = [6,0]; //select the date columns that should be transformed
var colors = ['yellow','white']; //color when true, color when false
//condition_value = '1.2' //set to the desired condition value
widget.on('ready', function(se, ev){
$.each(columns, function(index, value){
num = $("tbody tr:first").children().length - value;
var e = element;
var w = widget;
var d = dashboard;
$("tbody tr" , e).not('.wrapper, .p-head-content').each(function(){
var cell = $(this).children().last();
for (var a = 0; a < num; a++){
cell = cell.prev();
}
var cell_value = cell.text()
if ( cell_value % 1 != 0 && cell_value !== "Current Version" && cell_value !== "Days Since Last Version" && cell_value !== "it") {
$(cell).css("background-color", colors[0]);
}
else{
$(cell).css("background-color", colors[1]);
}
});
});
});