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
- Open the web map in Map Viewer and select the feature layer.
- On the Settings (light) toolbar, click Labels . Enable the labels by toggling Enable labels on.
- In the Label features pane, click Add label class. Under Label field, click Use expression .
- In the editor window, configure the expressions below.
- Replace <variable_name> with the desired variable name. In this example, 'ratio' is used.
- Replace <field_name> with the field's name to display the range of percentages with labels. In this example, 'Accident_Ratio' is selected.
- Replace <field_value> with the desired field’s values from the attribute table.
- 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.
- Click Done.
The web map below shows the range of percentages for the field displayed with labels.
Display the range of percentages with unique symbols
- Open the web map in Map Viewer and select the feature layer.
- On the Settings (light) toolbar, click Styles .
- In the Styles pane, for Choose attributes, click Expression.
- In the editor window, configure the expressions below.
- Replace <variable_name> with the desired variable name. In this example, 'ratio' is used.
- Replace <field_name> with the field's name to display the range of percentages. In this example, 'Accident_Ratio' is selected.
- Replace <field_value> with the desired field’s values from the attribute table.
- 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.
- Click Done.
- In the Styles pane, for Pick a style, select Types (unique symbols).
- In the Styles pane, click Done.
- 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.