- You have the styles swapped in the logic for “below” and “between”. I personally think it’s odd that you’ve assigned the area between two limits to be yellow, but I’m just here to help.
The following code works for me with the following conditions:
- There exists a Dataset with the following columns: “process_value”, “low_limit”, and “high_limit”.
- There exists three styles with the following names: “Above”, “Below”, and “Between”.
# Note: due to formatting issues, your script might throw a parse error here because it is encountering
# spaces instead of an indent. delete the spaces before output_json and replace them with
# indents. Do the same for this comment or remove it entirely.
output_json = []
style_red = {"classes": "Above"}
style_green = {"classes": "Below"}
style_yellow = {"classes": "Between"}
for row in range(value.getRowCount()):
row_object = {}
for col in value.getColumnNames():
cell_object={}
cell_style={}
cell_object['value']=value.getValueAt(row,col)
if col == 'process_value':
if value.getValueAt(row,col)>=value.getValueAt(row, 'low_limit') and value.getValueAt(row,col)<= value.getValueAt(row, 'high_limit'):
cell_style= style_yellow # between
elif value.getValueAt(row,col)>value.getValueAt(row, 'high_limit'):
cell_style= style_red
elif value.getValueAt(row,col)<value.getValueAt(row, 'low_limit'):
cell_style= style_green # below
cell_object['style']=cell_style
row_object[col]=cell_object
output_json.append(row_object)
return output_json