Please help, I've been trying for hours as someone with minimal arcade experience. Here is the code I have:
// Access related table
var relatedTable = FeatureSetByPortalItem(portal,
"558cb226d1cd403c9e9bfc5dacd8ea67", 1, ['station_id', 'record_date', 'E__coli'])
var station_id = Text($feature.station_id)
var relatedData = Filter(relatedTable, "station_id = @station_id") // If no related records exist, return null
if (Count(relatedData) == 0) {
return null
}
// Sort records by date (ascending)
var sortedData = OrderBy(relatedData, 'record_date ASC')
// Prepare lists for charting
var dates = []
var ecoliValues = []
for (var f in sortedData) {
// Convert date and E. coli values to the correct format
var formattedDate = Text(Date(f.record_date), 'MM/DD/YYYY')
var ecoliValue = Number(f.E__coli)
if (!IsEmpty(formattedDate) && !IsEmpty(ecoliValue)) {
Push(dates, formattedDate)
Push(ecoliValues, ecoliValue)
}
}
// Return correctly formatted data for ArcGIS Online Charts
return {
"labels": dates, // X-axis (dates)
"datasets": [
{
"label": "E. Coli Levels",
"data": ecoliValues // Y-axis (E. coli values)
}
]
}
I just need the chart to show E coli counts on the Y, and date on the X. The data is pulling correctly when populating the field, and it shows all related records in the pop-up table. As the code is now, the chart populates blank.