Select to view content in your preferred language

Popup Chart Assistance

635
1
Jump to solution
07-27-2023 06:59 AM
Labels (1)
bsklaohfl
Regular Contributor

Hi,

It seems my Arcade Script to create a pop up line chart has broken. The chart is visible in the popup, however no data populates. I am stumped because it was working fine a few weeks ago. Could someone please look at my code and help me troubleshoot?

 

Thanks,

		// Set variable to MRNLINK IDS
		var Road = $feature.MRNLINKID
		// Set variable to related table (notice FeatureSetByRelationshipName)
		var Table = FeatureSetByRelationshipName($feature, "ADT_Data_Merge", ['Mean_ADT', 'Year'], false)
		// filter through table, matching the table's STATIONID with road variable)
		var AADT = OrderBy(Filter(Table, 'StationID = @Road'), 'Year')
		// this was copied and pasted from AGO community post, I only changed certain variables
		var chartValues = {}
		var chartNames = []
		for (var f in AADT) {
		        chartValues[Text(f.Year,'0000')] = Text(f.Mean_ADT,'###,###')
		        Push(chartNames, f.Year)
		    }
		return {
		    type: 'media',
		    title : 'AADT by Year',
		    description : 'Annual average daily traffic by year for this road',
		    attributes : chartValues,  // replace this dictionary with your own key-value pairs,
		    mediaInfos: [{
		        type : 'linechart', //linechart | barchart | piechart | columnchart
		        //title : '',
		        //caption : '',
		        altText : 'line chart showing traffic counts by year', //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 
		        }	  
		      }]
		  }


Brooke

0 Kudos
1 Solution

Accepted Solutions
bsklaohfl
Regular Contributor

I figured it out! I think this may have to do with the June update which asks for numerical values when configuring a chart, but I'm not totally sure. I adjusted line 7 to call a numerical value, and the chart works! I hope this helps someone.

for (var f in AADT) {
        chartValues[Text(f.Year,'0000')] = Number(f.Mean_ADT,'###,###')

View solution in original post

0 Kudos
1 Reply
bsklaohfl
Regular Contributor

I figured it out! I think this may have to do with the June update which asks for numerical values when configuring a chart, but I'm not totally sure. I adjusted line 7 to call a numerical value, and the chart works! I hope this helps someone.

for (var f in AADT) {
        chartValues[Text(f.Year,'0000')] = Number(f.Mean_ADT,'###,###')
0 Kudos