Why don't all Arcade expressions work for Attribute-Driven Symbology?

576
0
09-19-2018 12:00 PM
NoeLandaverde
New Contributor

I have been trying to make bi- and multivariate maps on ArcGIS Pro to achieve effects similar to the smart mapping capabilities available on AGOL. For example, after allowing symbol property connections, I wrote the following code on the Expression Builder to change symbol fill colors depending on value ranges. I got no errors, but no colors were rendered:

var chg = ((($feature.Idx2018/1000) -
$feature.Idx2016)/$feature.Idx2016)*100; //calculate the percent change

var brks = [-25,-10,0,15,35,70,155]; //define class breaks
var clrPlt = [ //8 digit hex codes for each class
"#A8380090",
"#CD655590",
"#EC8D6D90",
"#F5F5F590",
"#BED6BE90",
"#7ECDAC90",
"#01857190"
];

When(chg < brks[0],clrPlt[0], //colors are returned when condition is true
(chg >= brks[0] && chg < brks[1]),clrPlt[1],
(chg >= brks[1] && chg < brks[2]),clrPlt[2],
(chg >= brks[2] && chg < brks[3]),clrPlt[3],
(chg >= brks[3] && chg < brks[4]),clrPlt[4],
(chg >= brks[4] && chg < brks[5]),clrPlt[5],
(chg >= brks[5] && chg < brks[6]),clrPlt[6],"#FFFFFF90"
);

After a lot of trials, I managed to get the result I wanted after "hard-coding" the color codes and the class breaks (the symbols below were being drawn with a single hue):

var chg = ((($feature.Idx2018/1000) - 
$feature.Idx2016)/$feature.Idx2016)*100; //calculate the percent change

When(chg < -25,"#A83800",
(chg >= -25 && chg < -10),'#CD6555',
(chg >= -10 && chg < 0),'#EC8D6D',
(chg >= 0 && chg < 15),'#F5F5F5',
(chg >= 15 && chg < 35),'#BED6BE',
(chg >= 35 && chg < 70),'#7ECDAC',
(chg >= 70 && chg < 160),'#018571',"#000"
);

Why is this happening? I think that for a lot of people, code blocks such as the one at the top of this description would be easier to maintain, if code reused consistently. I also tried doing this with if statements, one condition at a time; but it was rejected when comparing to a negative value... also something strange, as if Arcade was doing computations with a few random values to define whether conditions are true or not prior to running the whole thing. This last statement, of course is just an assumption

I would like to hear if indeed, there are issues with the language that must be fixed, or if I missed something.








0 Replies