I have a webmap I am attempted to set up a new pop-up element within. I have wrote in the following code, however it will only fully render if I change the type to piechart. Otherwise it only renders the background of the chart area but none of the data. I use the same code to also populate a fieldlist from the data in the same fashion and this works without fail.
Any ideas or suggestions would be welcome.
var use = FeatureSetById($map, "19403d43feb-layer-16");
var ptr = $feature.PTR_str;
var spec = Filter(use, "PTR = @ptr")
if(Count(spec) == 0){
return {
type : 'text',
text: 'No Usage History Available'
}
}
var spec2 = OrderBy(spec, "bill_date ASC")
var mos = Dictionary({
'0' : 'January',
'1' : 'February',
'2' : 'March',
'3' : 'April',
'4' : 'May',
'5' : 'June',
'6' : 'July',
'7' : 'August',
'8' : 'September',
'9' : 'October',
'10' : 'November',
"11" : 'December'
})
var atts = {}
var fldIns = []
var flds = []
var mo
var yr
var nm
var usage
for(var row in spec2){
mo = Text(Month(DateOnly(row['bill_date'])))
yr = Right(Text(Year(DateOnly(row['bill_date']))), 2)
nm = `${mos[mo]}${yr}`
usage = row['billed_usage']
push(fldIns, {fieldName : nm})
push(flds, nm)
atts[nm] = usage
}
var element = {
type: 'media',
// title : 'The title for all media in the element',
// description : '',
attributes : atts, // replace this dictionary with your own key-value pairs,
mediaInfos: [{
type : 'linechart', //linechart | barchart | piechart | columnchart
//title : 'give your chart a title',
// caption : '',
altText : '', //altText will be read by screen readers
value : {
fields: flds, // choose what attributes to use in the chart
/* colors: [ // values must be an array of [r, g, b, a] values (0-255)
[122, 190, 229, 255],
[179, 155, 213, 255],
[248, 174, 131, 255]
], */
//normalizeField : '', // the name of the attribute to normalize by or value
}
}]
}
return element