background color values in table based on certain conditions

Hello,

I am using Helical Insight 5.2.1. I have a requirement to change the background color of table cells based on certain conditions(condition formatting). I understand that the Color property is having background color but I want to define ranges and for that range of values what should be the color.

How can this be achieved?

Example: If a row value is above 10,000, display it in red; otherwise, use green

Yes, It it can be done using JavaScript.

Step1 : Open the tabular report in edit mode.
Step2 : Go to Operations>Post Execution

image

Inject below JS code :


let el = document.querySelectorAll('.hreport-table table tbody tr');
let index = 0;
el.forEach((item) =>{
if(index !== 0){
let row = item.querySelectorAll('td:nth-child(2)') // 2 is column index number(starts from 1) please define your column position here on which you want to define condition
let reqText = row[0].querySelector('div')
if(reqText.textContent >= 10000){  // define the condition
row[0].style.setProperty('background-color', 'red', 'important');
}else{
row[0].style.setProperty('background-color', 'green', 'important');
}
}
index ++;
})

image

Step 3: Click on ‘Apply’ and save the report