Arcade Question

638
4
02-01-2023 07:36 AM
AndrewIngall2
New Contributor

Hello all

I am trying to set the size of the font in my feature class based on the value of the height field using arcgis pro labelling.  I have set the expression to the following but it doesn't work. any ideas why??

"<FNT size = '10' * $feature.height>" + $feature.textstring + "</FNT>"

Regards

Andy

 

0 Kudos
4 Replies
JohannesLindner
MVP Frequent Contributor
var size = $feature.OBJECTID
return `<FNT size='${size}'>Test</FNT>`

JohannesLindner_0-1675266478040.png

 


Have a great day!
Johannes
0 Kudos
AndrewIngall2
New Contributor

Johnnes

Thanks for the reply which works fine when i type the text in for display but i am obviously missing something when i want to display the text automatically from the field textstring.

var size = $feature.height * 6.66
return `<FNT size='${size}'>$feature.textstring</FNT>`

 Please see the output on the image attached

Andy

0 Kudos
JohannesLindner
MVP Frequent Contributor
var size = $feature.height * 6.66
return `<FNT size='${size}'>${$feature.textstring}</FNT>`

 

https://developers.arcgis.com/arcade/guide/template-literals/


Have a great day!
Johannes
0 Kudos
Kepa
by Esri Contributor
Esri Contributor

Hi there,

This must be a syntax issue, try the following instead to skip size value between quotation marks (be careful not to forget single quotation mark at the end of the first part and in the beggining of the next one after $feature.height variable):

"<FNT size= '" + 10 * $feature.height + "'>" + $feature.textstring  + "</FNT>"

More info

Regards,

Kepa

Edit: @JohannesLindner  was faster, and better arcade syntax. Great!

0 Kudos