Select to view content in your preferred language

Pop-up Linechart Arcade, execution error

535
2
Jump to solution
11-22-2023 12:48 PM
Labels (2)
DavidFrisbey
Emerging Contributor
Hi ESRI community,
 
Currently, the below arcade script to render a linechart in a pop-up, that uses data from another not related or joined hosted feature service table, is showing this execution error:
DavidFrisbey_0-1700685368670.png

Does anyone have any advice or clue how to approach this error and correctly render a linechart in a popup using this type of arcade method?

 

 
 
 
//set variable to sensor_id
var nodes = $feature.sensor_id
//set variable to portal item to return from a feature table a feature set
var p = Portal("https://arcgis.com");
var ArchiveData = FeatureSetByPortalItem(
  p, "0749f4597e054caf809b5b55d0b869d4",
  0,
  ['sensor_id','time_stamp','pm25calibrated','avg_'],
  false
)
// filter through table, matching the table's sensor_id with sensor_id per feature in this layer (line2)
var AD = OrderBy(Filter(ArchiveData, 'sensor_id = @nodes'), 'time_stamp')
//relationship between
var chartValues = {}
var chartNames = []
// get time stmpt from current $feature
//Text($feature.EditDate_1693522081818, 'H:mm dddd MMMM D, Y')

 

for (var f in AD) {
        chartValues[Time(f.time_stamp, 'H:mm dddd MMMM D, Y')] = Number(f.pm25calibrated,'000')
        Push(chartNames, f.time_stamp)
    }

 

return {
    type: 'test',
    title : 'test',
    description : 'Chart showing prior hours of AQI values',
    attributes : chartValues,  // replace this dictionary with your own key-value pairs,
    mediaInfos: [{
        type : 'linechart', //linechart | barchart | piechart | columnchart
        //title : '',
        //caption : '',
        altText : 'line chart prior hours of AQI values', //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
        }  
      }]
  }
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

When you replace "Time" with "Text" in this line, your script works

chartValues[Text(f.time_stamp, 'H:mm dddd MMMM D, Y')] = Number(f.pm25calibrated,'000')

 

 

 

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

When you replace "Time" with "Text" in this line, your script works

chartValues[Text(f.time_stamp, 'H:mm dddd MMMM D, Y')] = Number(f.pm25calibrated,'000')

 

 

 

0 Kudos
DavidFrisbey
Emerging Contributor

Thank you, Ken, great help!

0 Kudos