Select to view content in your preferred language

How to add a pie chart to a pop-up using an Arcade expression

70
1
15 hours ago
Labels (2)
OliverIshmael
Occasional Contributor

I would like to add a pie chart to a popup on a map (using the new map viewer). My data looks like this: Nitrogen and Phosphorus Source Apportionment by Land Use Type - Data (arcgis.com)

I have no experience of using Arcade and most examples i can find online make use of JavaScript, which i also don't know. I found an example somewhere that i used as a template (see below) , but this doesn't seem to work on it's own:

 

return {
  type: "media",
  // defines attribute values calculated in the expression
  // values for all charts must be included here
  attributes: {
    field1: Number($feature.N_EXPORT_PC_SPRING_BARLEY),
    field2: Number($feature.N_EXPORT_PC_OTHER),
    field3: Number($feature.N_EXPORT_PC_GRASS),
    field4: Number($feature.N_EXPORT_PC_MAIZE),
    field5: Number($feature.N_EXPORT_PC_WINTER_BARLEY),
    field6: Number($feature.N_EXPORT_PC_WINTER_WHEAT),
    field7: Number($feature.N_EXPORT_PC_OILSEED_RAPE),
    field8: Number($feature.N_EXPORT_PC_SOLAR),
    field9: Number($feature.N_EXPORT_PC_SPRING_WHEAT),
    field10: Number($feature.N_EXPORT_PC_FIELD_BEANS),
    field11: Number($feature.N_EXPORT_PC_DISCONTINUOUS_URBAN),
    field12: Number($feature.N_EXPORT_PC_DUMP_SITES),
    field13: Number($feature.N_EXPORT_PC_INDUSTRIAL_OR_COMME),
    field14: Number($feature.N_EXPORT_PC_CONSTRUCTION_SITES),
    field15: Number($feature.N_EXPORT_PC_SPORT___LEISURE_FAC),
    field16: Number($feature.N_EXPORT_PC_CONTINUOUS_URBAN_FA),
    field17: Number($feature.N_EXPORT_PC_MINERAL_EXTRACTION_)
  },
  title: "Media content title",
  mediaInfos: [
    {
      type: "piechart",  // can also be "columnchart", "linechart", "piechart", "image"
      title: "Chart title",
      value: {
        // the list of attribute values to include in the chart
        fields: [ "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10", "field11", "field12",  "field13",  "field14",  "field15",  "field16",  "field17"   ]
      }
    }
  // you can define more charts here
  ]
}

 

 Can anyone tell me what else i need to add to make this work?

0 Kudos
1 Reply
binolmi
New Member

I believe it is possible if the csv is hosted online and you are using arcade attribute expressions. If the csv is a table hosted in the feature service that your well layer is on (published together from arcgis pro) then you could reference the table from a custom attribute display expression calling the fields from the same service.

0 Kudos