HOW TO

Create an ArcGIS Online Map Viewer pop-up pie chart displaying the top three values

Last Published: August 18, 2023

Summary

In ArcGIS Online Map Viewer, Arcade expressions can be used to display the top field values in a pop-up pie chart. This article provides an example and instructions using Arcade expressions to create a Map Viewer pop-up pie chart displaying the top three languages spoken at home in Caledon, Ontario, Canada.

Procedure

  1. Open the map in Map Viewer. Click Layers on the Contents (dark) toolbar and select the layer with the pop-up for editing.
  2. On the Settings (light) toolbar, click Pop-ups > Add content > Chart.
Note:
The following procedure (Steps 3b through 6) must be completed three times. One for each position of the top three values.
  1. In the Configure chart pane, click Pie and configure the following parameters:
    1. Specify a title for Title.
    2. Click Select fields > Add expression.
  2. In the editor window, specify a name for the new expression.
  3. In the Expression dialog box, insert the appropriate Arcade expression, as described below.
    1. Define the array of the target fields.
var <variableName1> = [
$feature.<fieldName1>,
$feature.<fieldName2>,
...
$feature.<fieldName214>
];
  1. Specify the following statement to sort the array from the highest to the lowest and return the field value based on the defined index number. The array index starts at 0.
  • For the top value, use the following script:
return Reverse(Sort(<variableName1>))[0]
  • For the second top value, use the following script:
return Reverse(Sort(<variableName1>))[1]
  • For the third top value, use the following script:
return Reverse(Sort(<variableName1>))[2]
The code block below shows the full working expression for the top value:
var lang_arr = [
$feature.MO_English,
$feature.MO_French,
$feature.MO_Hindi,
$feature.MO_Hungarian,
$feature.MO_Icelandic,
$feature.MO_Japanese,
$feature.MO_Korean,
$feature.MO_Krio,
$feature.MO_Ktunaxa_Kutenai,
$feature.MO_Malay,
$feature.MO_Malayalam,
$feature.MO_Mandarin,
$feature.MO_Mwani,
$feature.MO_Naskapi,
$feature.MO_Norwegian,
$feature.MO_Oneida,
$feature.MO_Oromo,
$feature.MO_Polish,
$feature.MO_Punjabi_Panjabi,
$feature.MO_Romanian,
$feature.MO_Rundi_Kirundi,
$feature.MO_Russian,
$feature.MO_Serbian,
$feature.MO_Serbo_Croatian,
$feature.MO_Sindhi,
$feature.MO_Spanish,
$feature.MO_Swedish,
$feature.MO_Tagalog_Pilipino_Filipino,
$feature.MO_Tamil,
$feature.MO_Turkish,
$feature.MO_Ukrainian,
$feature.MO_Urdu,
$feature.MO_Vietnamese,
$feature.MO_Wu_Shanghainese,
$feature.MO_Yiddish,
$feature.MO_Yoruba,
$feature.MO_Yue_Cantonese
];

return Reverse(Sort(lang_arr))[0]
  1. Click Run for a preview of the expression result. If the required result is achieved, click Done.
Specifying the Arcade expression in the ArcGIS Online Map Viewer editor window
  1. After the three expressions are created, select them as the target field.
Three expression selected in the Select fields window
Note:
To reference the field names related to the field values displayed in the pop-up, create a legend. Refer to How To: Create an ArcGIS Online Map Viewer pop-up pie chart legend displaying the top values for instructions.

The newly configured pop-up pie chart below shows the top three languages spoken at home in Caledon, Ontario, Canada.

The pop-up in ArcGIS Online Map Viewer with the newly configured pie chart

Article ID: 000030642

Software:
  • ArcGIS Online

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

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options