I'm attempting to vary the color of a specific word depending on what is added (critical, high, medium, or low), but the only color showing up is the yellow (#ecf229) from the else statement. Does anyone know what I'm getting wrong with the if/else statement? I believe that's where the issue might be but I'm not certain.
Here's the expression I've added to the advanced formatting for the list.
var lOI = ''
if ($datapoint.level_of_impact=="Critical"){lOI= '#e01d1d'}
else if($datapoint.level_of_impact=="High"){lOI= '#ff7300'}
else if($datapoint.level_of_impact=="Medium"){lOI= '#73b2ff'}
else {lOI= '#ecf229'}
return {
textColor: '',
backgroundColor: '',
separatorColor:'',
selectionColor: '',
selectionTextColor: '',
attributes: {
attribute1: lOI
// attribute2: ''
}
}
Here's what I have in the source for the line item template, which seems to be working correctly as it is adding a color - just not always the correct one.
<p><strong><span style="color:{expression/attribute1}">{level_of_impact}</span></strong></p>