HOW TO

Label or style a feature layer with a range of percentages using ArcGIS Arcade in Map Viewer

Last Published: May 10, 2024

Summary

In ArcGIS Online and Portal for ArcGIS Map Viewer, it is helpful to style or label numeric data in a feature layer using a range of percentages for better data management. In this article, an Arcade expression is used to create labels or style a feature layer with the desired range of percentages.

Procedure

Display the percentage range with labels

  1. Open the web map in Map Viewer and select the feature layer.
  2. On the Settings (light) toolbar, click Labels Labels icon.png. Enable the labels by toggling Enable labels on.
  3. In the Label features pane, click Add label class. Under Label field, click Use expression Use expression icon.png.
  4. In the editor window, configure the expressions below.
    1. Replace <variable_name> with the desired variable name. In this example, 'ratio' is used.
    2. Replace <field_name> with the field's name to display the range of percentages with labels. In this example, 'Accident_Ratio' is selected.
    3. Replace <field_value> with the desired field’s values from the attribute table.
    4. Replace <range of percentages> with the desired text for the labels.
var <variable_name> = $feature.<field_name>

if (<variable_name> <=<field_value>) {
    return "<range of percentage>";
} else if (<variable_name> <=<field_value> ) {
    return "<range of percentage>";
} else if (<variable_name> <=<field_value> ) {
    return "<range of percentage>";
} else {
    return "<range of percentage>";
}
Note:
The numbers for the range can be specified as per the requirements of the field’s attribute value.
  1. Click Done.
Label expression configured with Arcade expression.

The web map below shows the range of percentages for the field displayed with labels.

Web map displaying the range of accident ratio as labels.png

Display the range of percentages with unique symbols

  1. Open the web map in Map Viewer and select the feature layer.
  2. On the Settings (light) toolbar, click Styles Styles icon.png.
  3. In the Styles pane, for Choose attributes, click Expression.
  4. In the editor window, configure the expressions below.
    1. Replace <variable_name> with the desired variable name. In this example, 'ratio' is used.
    2. Replace <field_name> with the field's name to display the range of percentages. In this example, 'Accident_Ratio' is selected.
    3. Replace <field_value> with the desired field’s values from the attribute table.
    4. Replace <range of percentages> with the desired text for the legend.
var <variable_name> = $feature.<field_name>

if (<variable_name> <=<field_value>) {
    return "<range of percentage>";
} else if (<variable_name> <=<field_value> ) {
    return "<range of percentage>";
} else if (<variable_name> <=<field_value> ) {
    return "<range of percentage>";
} else {
    return "<range of percentage>";
}
Note:
The numbers for the range can be specified as per the requirements of the field’s attribute value.
  1. Click Done.
Arcade expression configuration for the styles.png
  1. In the Styles pane, for Pick a style, select Types (unique symbols).
  2. In the Styles pane, click Done.
  3. Display the legend representing the range of percentages for the values of the field. Refer to ArcGIS Online: View a legend (Map Viewer) or Portal for ArcGIS: View a legend (Map Viewer) for instructions.

The web map below shows the range of percentages represented through the unique symbols in the legend.

Web map displaying percentage range of field values with unique symbol style.png

Article ID: 000032559

Software:
  • Online
  • Portal for ArcGIS
  • ArcGIS Enterprise 11 0
  • ArcGIS Enterprise 11 1
  • ArcGIS Enterprise 11 2

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options