Select to view content in your preferred language

Creating a background color based on a field value using Arcade

90
4
Wednesday
Labels (2)
NathanGabbard
Emerging Contributor

Hello,

I'll start off by saying that I'm not very good at coding. Trying to think outside the box when I don't even know what the box is, is making for some difficult times, but I'm trying!

I'm trying to create a background color based on a field value using arcade, this is going in the Title location under pop-ups. I was able to create a box color for the text using HTML however that wasn't based on any values. The picture below is what I'm basically trying to accomplish. Each color matches the icons on the map 

In Warranty = Purple

In Development Review = Yellow

Approved = Green

Under Construction = Orange

 

NathanGabbard_0-1753912208733.png

Any help would be greatly appreciated. I've looked at several guides and tried using the AI generator but didn't have much luck with either.

 

0 Kudos
4 Replies
JonathanMcD
Frequent Contributor

There's an ESRI blog that will help you on your way.

Spruce up your pop-ups with CSS

As well as this map; Flexbox CSS examples

I found them really useful I then created pop-ups that related directly to the symbology in a few maps I publish. For example, I publish an ownership map which contains 6 different status types, I can reflect the colour of the symbology within the pop-up. You will create a simple Arcade Expression for the symbology colours, then it's that reference that's added into your pop-up text box html.

Don't worry, the two example links makes it all quite clear and you can copy out the scripts used too.

Below is an example of what I did from the two pages linked;

JonathanMcD_0-1753923130349.png

Following is the code for the top text box;

JonathanMcD_1-1753923371406.png

The popup for this dataset is just a series of text boxes with either the code to create layouts or <hr> to create the line.

This is just part of the code for the rest of the pop-up. You can see, once you get your head around how the columns work, it's a case of copy/paste for your own use.

JonathanMcD_2-1753923961407.png

and finally, this is an example of the expression to define the colours.

JonathanMcD_3-1753924026449.png

 

(PS - I'm not a coder or anything like that, I just had ideas on what I want to do with pop-ups, so for those that know way more than me, please don't pick holes in what I've done .... 🙂  )

 

NathanGabbard
Emerging Contributor

Thank you! I was looking at pop-ups the essential guides and didn't come across this one.

0 Kudos
NathanGabbard
Emerging Contributor

So I gave it a shot, and I had tried something similar to this yesterday and got the same results. 

NathanGabbard_0-1753970030941.png

My titles look like this:

NathanGabbard_1-1753970064351.png

Clearly I'm doing something wrong but following all the examples, I don't know what.

 

 

0 Kudos
JonathanMcD
Frequent Contributor

So, whilst you can change the colours of Text Boxes in the pop-up, you can't change the pop-up Title background. As you can see, you can use that field for an expression return and you can see your expression working.

The colour management is in the Text Box HTML - as you can see by the full view of my pop-up.

JonathanMcD_0-1753998567613.png

JonathanMcD_3-1753998820777.png

 

JonathanMcD_1-1753998692722.pngJonathanMcD_2-1753998738205.png

 

 

0 Kudos