Arcade: How do I get part of a label to change color?

3421
7
01-16-2020 12:58 PM
GISAdmin7
New Contributor II

Is it possible to have the X in the label Display in red?

Example :

719: X

I've tried this:

'<CLR red = "255">(": X")</CLR>'
7 Replies
XanderBakker
Esri Esteemed Contributor

Hi Danville_GIS ,

There is no support voor defining colors and font style with Arcade in your labels at this moment. The only thing I can think of is to duplicate the layer and filter for this "Test" value and define the label color for each layer.

KellyKoenig
Occasional Contributor

Seconding Xander Bakker‌ to say there is no current support, unfortunately. 

If you want to avoid having separate layers, you could create two expressions that would return each half of your if statement separately so you can apply HTML formats in the custom attribute display.

First Custom Expression {expression/expr0}

if ($feature.["FD_Status"] == 'Test') {
    return '✓'
}
else {
    return ''
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Second Custom Expression {expression/expr1}

if ($feature.["FD_Status"] == 'Test') {
    return ''
}
else {
    return '☓'
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Then in your custom attribute display, you would enter this in the html editor:

{FACILITYID}: {expression/expr0}<font color="#ff0000">{expression/expr1}</font>

It's cumbersome, but it's the best workaround I've found to control colors/styles on specific features.

P.S. I could have sworn I up-voted an ArcGIS Idea about including this kind of HTML in the AGOL attribute expression builder, but I can't find it now. If anyone remembers an idea like this, please post the link! Or create the idea and let us know so we can up-vote that one

LeLuong
New Contributor III

Hi,

Do you know if there's is support for defining colors and font style with Arcade in your labels now ?  Thank you.

AmirBar-Maor
Esri Regular Contributor

@LeLuong 

You can format your labels (color, font, font size...) in ArcGIS Pro.

More information in this help topic

0 Kudos
SFM_TravisBott
Occasional Contributor II

@XanderBakker@AmirBar-Maor  - Are there any updates here? Is there any plan to support this type of label configuration in ArcGIS Online?

Arcade is touted for it's ability to move between platforms, which is great when it works....until it doesn't. Basic globals like TextFormatting.NewLine (even though it's clearly listed as an option in expression construction), as well as formatting tags like the example above don't translate to AGOL. Which is a bummer. Can you offer insight?

0 Kudos
CraigWilliams
Esri Contributor

TextFormatting.NewLine is supported in the new Map Viewer and the 4.x JavaScript API.

Text Formatting tags aren't an Arcade feature, they're a text symbol feature supported in ArcMap, ArcGIS Pro, and ArcGIS Runtime. I'd suggest submitting an Idea for the JavaScript API / Map Viewer for similar support conversations.

SFM_TravisBott
Occasional Contributor II

Thanks, @CraigWilliams for the tip about the new Map Viewer. I was unaware of that change. 

If you're suggesting submitting an Idea in reference to the original post, I don't think one should have to. If the advertised purpose of the language is to move between platforms it should, you know, actually move between platforms. If a layer has a Arcade-formatted labeling expression in Pro it shouldn't be sabotaged once published to AGOL. Just my two cents.