I'd like to build a table in a popup that shows a matrix of different attribute values while formatting the cell background colors using the same range, e.g.
≤70% = red
70% to ≤80% = orange
80% to ≤90% = yellow
90% to ≤95% = green
>95% = blue
I have 30 different attribute values in the matrix table and I have to believe there's a better way to do this in arcade than writing an if else statement for each?
You can write a function that returns the color for the attribute passed in as a parameter.
function bgColor(attribute) {
when (attribute <= 70, "red",
attribute <= 80, "orange",
attribute <= 90, "yellow",
attribute <= 95, "green",
"blue")
}
//in use
var theColor = bgColor($feature.attribute)