<?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 Arcade expression for pop-up chart to display average rainfall 30 days prior to a defect in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-pop-up-chart-to-display/m-p/1295364#M52560</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi, I'm wondering if any Arcade experts can help me please? Using the below expression, I am able to list out the average rainfall in mm prior to a defect report date.&lt;/SPAN&gt;&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var weather = FeatureSetByName($map, "Weather Stations", ["*"], false)
 
var station = $feature.Closest_WeatherStation
var defectdate = $feature.Reported_Date___Time
var startDate = DateAdd(defectdate, -30, "days");
var endDate = DateAdd(defectdate, -1, "days");
var query = "Station = @station AND Date_Field &amp;gt;= @startDate AND Date_Field &amp;lt;= @endDate "
var filtered_weather = Filter(weather, query)
 
var return_lines = [

Count(filtered_weather) + " days forecast",

]

for(var d in filtered_weather) {

Push(return_lines, "Total Rainfall " + d.Daily_Total_Rainfall__0900_0900 + " mm")
}
return Concatenate(return_lines, Textformatting.NewLine)&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, rather than a list, I would like to display my results in a bar chart, displaying the date on the x axis and the average rainfall for each date up to 30 days before the defect date on the y axis. Is anyone able to help with this please?&lt;/P&gt;&lt;P&gt;I have tried this following the page&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/part-2-introducing-arcade-pop-up-content-elements/" target="_blank" rel="nofollow noopener noreferrer"&gt;Part 2: Introducing Arcade Pop-up Content Elements (esri.com)&lt;/A&gt;&amp;nbsp;and come up with the below:&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var weather = FeatureSetByName($map, "Weather Stations", ["*"], false)
 
var station = $feature.Closest_WeatherStation
var defectdate = $feature.Reported_Date___Time
var startDate = DateAdd(defectdate, -30, "days");
var endDate = DateAdd(defectdate, -1, "days");
var query = "Station = @station AND Date_Field &amp;gt;= @startDate AND Date_Field &amp;lt;= @endDate "
var filtered_weather = Filter(weather, query)
 
var return_lines = Average(filtered_weather)

var rainfall = groupBy(return_lines, 'Daily_Total_Rainfall__0900_0900',
                {name:'average', expression:'Daily_Total_Rainfall__0900_0900' , statistic:'AVERAGE'})

var chartValues = {}
var chartNames = []
for (var f in rainfall) {
        chartValues[f.Daily_Total_Rainfall__0900_0900] = f.average
        Push(chartNames, f.Date_Field)
    }

return {
    type: 'media',
    title : 'Rainfall by Date',
    description : 'Chart showing total rainfall 30 days prior to defect report date',
    attributes : chartValues,  // replace this dictionary with your own key-value pairs,
    mediaInfos: [{
        type : 'columnchart', //linechart | barchart | piechart | columnchart
        //title : '',
        //caption : '',
        altText : 'bar chart showing average rainfall by date', //altText will be read by screen readers
        value : {
          fields: chartNames,  // choose what attributes to use in the chart
          //normalizeField : '',  // the name of the attribute to normalize by or value 
        }	  
      }]
  }&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;&lt;P&gt;&amp;nbsp;&lt;/P&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>Fri, 02 Jun 2023 14:00:27 GMT</pubDate>
    <dc:creator>cat206</dc:creator>
    <dc:date>2023-06-02T14:00:27Z</dc:date>
    <item>
      <title>Arcade expression for pop-up chart to display average rainfall 30 days prior to a defect</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-pop-up-chart-to-display/m-p/1295364#M52560</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, I'm wondering if any Arcade experts can help me please? Using the below expression, I am able to list out the average rainfall in mm prior to a defect report date.&lt;/SPAN&gt;&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var weather = FeatureSetByName($map, "Weather Stations", ["*"], false)
 
var station = $feature.Closest_WeatherStation
var defectdate = $feature.Reported_Date___Time
var startDate = DateAdd(defectdate, -30, "days");
var endDate = DateAdd(defectdate, -1, "days");
var query = "Station = @station AND Date_Field &amp;gt;= @startDate AND Date_Field &amp;lt;= @endDate "
var filtered_weather = Filter(weather, query)
 
var return_lines = [

Count(filtered_weather) + " days forecast",

]

for(var d in filtered_weather) {

Push(return_lines, "Total Rainfall " + d.Daily_Total_Rainfall__0900_0900 + " mm")
}
return Concatenate(return_lines, Textformatting.NewLine)&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, rather than a list, I would like to display my results in a bar chart, displaying the date on the x axis and the average rainfall for each date up to 30 days before the defect date on the y axis. Is anyone able to help with this please?&lt;/P&gt;&lt;P&gt;I have tried this following the page&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/part-2-introducing-arcade-pop-up-content-elements/" target="_blank" rel="nofollow noopener noreferrer"&gt;Part 2: Introducing Arcade Pop-up Content Elements (esri.com)&lt;/A&gt;&amp;nbsp;and come up with the below:&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var weather = FeatureSetByName($map, "Weather Stations", ["*"], false)
 
var station = $feature.Closest_WeatherStation
var defectdate = $feature.Reported_Date___Time
var startDate = DateAdd(defectdate, -30, "days");
var endDate = DateAdd(defectdate, -1, "days");
var query = "Station = @station AND Date_Field &amp;gt;= @startDate AND Date_Field &amp;lt;= @endDate "
var filtered_weather = Filter(weather, query)
 
var return_lines = Average(filtered_weather)

var rainfall = groupBy(return_lines, 'Daily_Total_Rainfall__0900_0900',
                {name:'average', expression:'Daily_Total_Rainfall__0900_0900' , statistic:'AVERAGE'})

var chartValues = {}
var chartNames = []
for (var f in rainfall) {
        chartValues[f.Daily_Total_Rainfall__0900_0900] = f.average
        Push(chartNames, f.Date_Field)
    }

return {
    type: 'media',
    title : 'Rainfall by Date',
    description : 'Chart showing total rainfall 30 days prior to defect report date',
    attributes : chartValues,  // replace this dictionary with your own key-value pairs,
    mediaInfos: [{
        type : 'columnchart', //linechart | barchart | piechart | columnchart
        //title : '',
        //caption : '',
        altText : 'bar chart showing average rainfall by date', //altText will be read by screen readers
        value : {
          fields: chartNames,  // choose what attributes to use in the chart
          //normalizeField : '',  // the name of the attribute to normalize by or value 
        }	  
      }]
  }&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;&lt;P&gt;&amp;nbsp;&lt;/P&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>Fri, 02 Jun 2023 14:00:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-pop-up-chart-to-display/m-p/1295364#M52560</guid>
      <dc:creator>cat206</dc:creator>
      <dc:date>2023-06-02T14:00:27Z</dc:date>
    </item>
  </channel>
</rss>

