Creating a chart through arcade expression in popups

303
2
Jump to solution
02-15-2024 11:04 AM
Labels (1)
ZhongmingAn
New Contributor III

Hi,

I am trying to add charts to my popups and was able to get the result from the image below:

ZhongmingAn_0-1708023352006.png

but in my popup the chart just kept loading and refused to show up at all:

ZhongmingAn_1-1708023526072.png

I'd appreciate it if anyone could shed some light on what I did wrong. Thanks.

Here is my Arcade expression:

var a = FeatureSetByName($datastore, 'Data', ['Bldg_Num', 'Room_Type_Description', 'ASF'])
var bn = $feature.BuildingNumber
var v = Filter(a, 'Bldg_Num=@bn')
var stats = GroupBy(v, 'Room_Type_Description', {name: 'Area', expression: 'ASF', statistic: 'SUM'})
var allSpcTP = OrderBy(stats, 'Area')

var Values = {}
var pieNames = []

for (var i in allSpcTP){
  Values[i.Room_Type_Description]= Number(i.Area);
  Push(pieNames, i.Room_Type_Description)
}


return {
  type: "media",
  attributes:Values,
  mediaInfos:{
    type: "barchart",
    title: 'Room type sqare footage',
    value: {
      fields: pieNames
    }
  }
}

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JohnEvans6
Occasional Contributor

I think its that mediaInfos should be an array since you can have multiple charts:

return {
  type: "media",
  attributes:Values,
  mediaInfos:[{
    type: "barchart",
    title: 'Room type sqare footage',
    value: {
      fields: pieNames
    }
  }]
}

View solution in original post

2 Replies
JohnEvans6
Occasional Contributor

I think its that mediaInfos should be an array since you can have multiple charts:

return {
  type: "media",
  attributes:Values,
  mediaInfos:[{
    type: "barchart",
    title: 'Room type sqare footage',
    value: {
      fields: pieNames
    }
  }]
}
ZhongmingAn
New Contributor III

Thank you! It works.

You just saved me from insanity...

0 Kudos