Select to view content in your preferred language

Arcade Assign Attributes in List Individual Colors based on IIF

577
13
Jump to solution
11-05-2024 01:20 PM
Ed_
by MVP Regular Contributor
MVP Regular Contributor

So i have three attributes in the list, "severity", "probability" and date. I would like to show severity in red when its value is "Severe" and probability red as well when its value is "Likely". Second, i wouldn't like the date to have any color change. 

I know i have to use HTML source formatting in conjunction with Arcade for this purpose. How can I do this?

Bonus question: How can i please add a calendar icon next to the date? Please note that the date is in the second line

Current output:

Ed__0-1730841601856.png

 



Thank you 🙂

 

Current Arcade:

/ Condition Color the Attributes
var colorS = IIF($datapoint.severity == "Severe", "#ff0000", '')
var colorP = IIF($datapoint.probability == "Likely", "#ff0000", '')


return {
  textColor: colorS,
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
  // attributes: {
    // attribute1: '',
    // attribute2: ''
  // }
}

 

Current HTML source:


<p>
    <strong>{field/severity}, {field/probability}</strong><br>
    {field/date_and_time}
</p>

 

Question | Analyze | Visualize
0 Kudos
13 Replies
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Hi Jen, that worked cheers 🙂 🎉

now how can i please add a clock or calendar icon/emoji next to the date and time field value?

 

// Condition Color the Attributes
var colorS = IIF($datapoint.how_severe_could_the_injury_to == "Severe", "#ff0000", '')
var colorP = IIF($datapoint.what_is_the_probability_that_in == "Likely", "#ff0000", '')


return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
  attributes: {
    attribute1: colorS,
    attribute2: colorP
  // }
}
}

 

 

 

<p>
    <span style="color:{expression/attribute1};"><strong>{field/how_severe_could_the_injury_to}</strong></span>, <span style="color:{expression/attribute2};"><strong>{field/what_is_the_probability_that_in}</strong></span>
</p>
<p>
    {field/date_and_time}
</p>

 

 

Ed__0-1730920125649.png

 

 

Question | Analyze | Visualize
0 Kudos
Ed_
by MVP Regular Contributor
MVP Regular Contributor

so far i came up with the following in the Arcade expression

var cal_emoji = [':tear_off_calendar:']
Question | Analyze | Visualize
0 Kudos
JenniferAcunto
Esri Regular Contributor

Just add the emoji in the line item template next to your field: {field/date_and_time} :alarm_clock:

JenniferAcunto_0-1730921115306.png

 

- Jen
Ed_
by MVP Regular Contributor
MVP Regular Contributor

yup that worked like a charm thank you so much for your time and help @JenniferAcunto  🙂

Ed__0-1730922157018.png

 

Question | Analyze | Visualize