Hello,
I'm trying to using a single when statement to change the background color of a list element. My arcade returns no errors but work as expected. Here's my code sample:
var co = IIF($datapoint.CleanoutNeeded == 'Yes', "Cleanout Needed", "");
var cb = IIF($datapoint.CBMarkerNeeded == 'Yes', "CB Marker Needed", "");
var id = IIF($datapoint.IllicitDischarge == 'Yes', "Illicit Discharge", "");
var sd = IIF($datapoint.StructuralDamage == 'Yes', "Structural Damage", "");
var other = IIF($datapoint.OtherIssues == 'Yes', "Other Issues - see data", "");
var color = When(
$datapoint.IllicitDischarge == 'Yes', "#b51963",
$datapoint.CleanoutNeeded == 'Yes', "#c44601", '')
return {
textColor: '',
backgroundColor: '',
attributes: {
attribute1: color
},
separatorColor:'',
selectionColor: '',
selectionTextColor: '',
attributes: {
co: co,
cb: cb,
id: id,
sd: sd,
other: other
}
}
Any ideas?
Thanks,
Zac
Set backgroundColor color directly. You have added some additional unnecessary attributes
return {
textColor: '',
backgroundColor: color,
separatorColor:'',
selectionColor: '',
Thank you! That approach works fine but I actually want to change the individual elements of the background color as show in this image:
Any ideas?
It sounds like you want to change the background color of your font. You would need to use HTML to do that along with your Arcade. Add your color to the rest of the attributes instead of trying to force it into the background color section of your return statement. Then in the rich text editor for your list, add a background font color to the desired text element. It doesn't matter what color you pick.
Then go into the source to view the HTML, replace the hex code in the HTML with your Arcade color attribute.
This post walks you through how to do this for a table background, but the general process is the same.
Thanks @JenniferAcunto this is exactly wheat I needed.