Hi,
I am trying to control the background color of a list element using an arcade expression. The $datapoint.division contains several string values e.g. Central Arizona. Ideally I would like this expression to execute based on the various division values and color code the background of each list element based on the string value of $datapoint.division.
Here is my expression. @DougBrowning , figured you can solve this in the blink of an eye.
var color = IIF($datapoint.division == "Central Arizona", '#F3DED7', '')
return {
textColor: '',
backgroundColor: color,
separatorColor:'',
selectionColor: '',
selectionTextColor: '',
// attributes: {
// attribute1: '',
// attribute2: ''
// }
}
Solved! Go to Solution.
Have you double checked your Division values? You want to use the name value and not the label. Are you using the Globals tab to add your field to your expression? If not, do that so that you know the syntax is correct. Also, try returning it as an attribute and then simply calling that in your list. That way you can see what, if anything your statement is returning.
Is this post attempting the same idea?
var color = When(
$datapoint.division == 'Central Arizona', '#F3DED7',
$datapoint.division == 'Northern Arizona', '#981e1d',
$datapoint.division == 'Southern Arizona', '#f7b538', '')
Hi Jennifer, thank you for the input.
I have applied the arcade expression and set textColor: color to call my variable color. No results. Is there a step I am missing?
var color = When(
$datapoint.division == 'Central Arizona', '#AC734A',
$datapoint.division == 'Piaute Pipeline', '#84AC4A',
$datapoint.division == 'Southern Nevada', '#4A99AC', '')
return {
textColor: color,
backgroundColor: '',
separatorColor: '',
selectionColor: '',
selectionTextColor: '',
// attributes: {
// attribute1: '',
// attribute2: ''
// }
}
Have you double checked your Division values? You want to use the name value and not the label. Are you using the Globals tab to add your field to your expression? If not, do that so that you know the syntax is correct. Also, try returning it as an attribute and then simply calling that in your list. That way you can see what, if anything your statement is returning.
Thank you Jennifer!
Hi @JenniferAcunto ,
Hope all is well, so I too have a color related question, figured I should ask it here. Based on the code (template literals,) below how can I change the color individually of each text string and field value?
Code:
for (var f in intersectLayer){
popup += `<b>Area:</b> ${f.AREAFT} <br><br>
<b>Length:</b> ${f.LENFT} <br><br>
<b>ID:</b> ${f.ID} <br><br>
`
}
Desired Output:
Area: Value
Length: Value
ID: Value
I'm not really an Arcade person. I just know a few tricks I use for Dashboards. I recommend you post this as a question so that the general community can see it.
No worries and thank you for the quick response 🙂