<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Custom Arcade Chart in Popup in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1417901#M59000</link>
    <description>&lt;P&gt;I'm trying to create a chart that displays in a popup, from features in another layer using the current layer as a filter. I have the following code returning the appropriate FeatureSet filtered and grouped as I would like. But the format appears to be incorrect. I can't work out what the correct format is to have the chart actually display the data in the featureset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var state = $feature.AALRegion;

var portal = Portal('https://www.arcgis.com');

var fields = [
    'OBJECTID',
    'Region',
    'gridcode',
    'Hectares'
];

var fs = FeatureSetByPortalItem(
    portal,
    '7369e87b3b104eae8c18507261184083',     // FeatureService ID that you want to grab fields from.
    0,                                      // Sublayer index, usually 0.
    fields,                                 // Array of fields to grab from the FeatureService.
    False                                   // Include geometry?
);

var final = GroupBy(Filter(fs,"Region = @state"),'gridcode',
      {
        name: 'sumhec',
        expression: 'Hectares',
        statistic: 'SUM'
    },
);
    
return final&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BlakeMorrison_0-1714621206915.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/102771iAE4C8B77C335A24D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BlakeMorrison_0-1714621206915.png" alt="BlakeMorrison_0-1714621206915.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2024 03:39:18 GMT</pubDate>
    <dc:creator>BlakeMorrison</dc:creator>
    <dc:date>2024-05-02T03:39:18Z</dc:date>
    <item>
      <title>Custom Arcade Chart in Popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1417901#M59000</link>
      <description>&lt;P&gt;I'm trying to create a chart that displays in a popup, from features in another layer using the current layer as a filter. I have the following code returning the appropriate FeatureSet filtered and grouped as I would like. But the format appears to be incorrect. I can't work out what the correct format is to have the chart actually display the data in the featureset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var state = $feature.AALRegion;

var portal = Portal('https://www.arcgis.com');

var fields = [
    'OBJECTID',
    'Region',
    'gridcode',
    'Hectares'
];

var fs = FeatureSetByPortalItem(
    portal,
    '7369e87b3b104eae8c18507261184083',     // FeatureService ID that you want to grab fields from.
    0,                                      // Sublayer index, usually 0.
    fields,                                 // Array of fields to grab from the FeatureService.
    False                                   // Include geometry?
);

var final = GroupBy(Filter(fs,"Region = @state"),'gridcode',
      {
        name: 'sumhec',
        expression: 'Hectares',
        statistic: 'SUM'
    },
);
    
return final&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BlakeMorrison_0-1714621206915.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/102771iAE4C8B77C335A24D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BlakeMorrison_0-1714621206915.png" alt="BlakeMorrison_0-1714621206915.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 03:39:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1417901#M59000</guid>
      <dc:creator>BlakeMorrison</dc:creator>
      <dc:date>2024-05-02T03:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Arcade Chart in Popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1418046#M59011</link>
      <description>&lt;P&gt;You'll have to use an Arcade element instead of a chart. This uses the "media" &lt;A href="https://developers.arcgis.com/web-map-specification/objects/popupElement_media/" target="_self"&gt;popupElement&lt;/A&gt; in the return. Here's an example with your code that creates a basic bar chart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var state = $feature.AALRegion;

var portal = Portal('https://www.arcgis.com');

var fields = [
    'OBJECTID',
    'Region',
    'gridcode',
    'Hectares'
];

var fs = FeatureSetByPortalItem(
    portal,
    '7369e87b3b104eae8c18507261184083',     // FeatureService ID that you want to grab fields from.
    0,                                      // Sublayer index, usually 0.
    fields,                                 // Array of fields to grab from the FeatureService.
    False                                   // Include geometry?
);

var final = GroupBy(Filter(fs,"Region = @state"),'gridcode',
      {
        name: 'sumhec',
        expression: 'Hectares',
        statistic: 'SUM'
    },
);
    
var Values = {};
var barNames = [];

for (var i in final) {
  Values[Text(i.gridcode)] = i.sumhec; //you have to use a Text string for the Value keys. It doesn't work with numbers
  Push(barNames, i.gridcode)
}


return {
  type: "media",
  attributes:Values,
  mediaInfos:[{
    type: "barchart",
    title: `Sum of ${state}`,
    value: {
      fields: barNames
    }
  }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 13:17:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1418046#M59011</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-05-02T13:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Arcade Chart in Popup</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1419725#M59081</link>
      <description>&lt;P&gt;Thanks mate! That works straight away.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Over the weekend I realised what I was doing was more suitable for the Arcade element as opposed to the Chart element (which would need multiple data expressions to do what I wanted). Thank you for your perfect answer.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 01:45:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/custom-arcade-chart-in-popup/m-p/1419725#M59081</guid>
      <dc:creator>BlakeMorrison</dc:creator>
      <dc:date>2024-05-07T01:45:54Z</dc:date>
    </item>
  </channel>
</rss>

