Creating Dashboard elements with GeoJSON

668
3
02-08-2021 10:25 AM
Wirescan
New Contributor

Hello! So we have been using the ArcGIS Dashboard for some time and we are now making use of the recently added submodule arcgis.apps.dashboard.

One of the issuess we are facing is creating a dashboard elements(charts,gauge etc) with GeoJSON related data. When the Python API tries to create a Dashboard chart element, it usually looks after table data. But since we are dealing with GeoJSON, the data it is stored in propertie objects and not tables.

File "D:\Anaconda\envs\agol_env\lib\site-packages\arcgis\apps\dashboard\_gauge\_gauge.py", line 507, in objectid_field

    return self._item.tables[0].properties["objectIdField"]

IndexError: list index out of range

Creating dashboard elements with GeoJSON related object works fine manually on the ArcGIS Online website.

0 Kudos
3 Replies
MehdiPira1
Esri Contributor

Hi @Wirescan ,

No sure exactly what you're trying to achieve.

Is it possible to share your script?

0 Kudos
Wirescan
New Contributor

All 3 elements are taking advantage of the same feature layer. The difference is that element 3 is requiring it through a webmap widget.

Here is the script:

 

### ITEMS
item_name= 'Faerder Cable Network As Found'
item_geojson_related = gis.content.search(query='title: "{0}"'.format(item_name), max_items=1, item_type='Feature Layer')[0]

webmap_name = 'Faerder Windmill Park Static View'
webmap_item = gis.content.search(query='title: "{0}"'.format(webmap_name), max_items=1, item_type='Web Map')[0]
webmap = WebMap(webmap_item)
### DASHBOARD ELEMENTS

# Element 1 - Cable Capacitance
capacitance_chart = SerialChart(item_geojson_related, name='Cable Capacitance', categories_from='features', description='Cable Capacitance')
capacitance_chart.data.category_field = 'CableID'
capacitance_chart.data.add_value_field('Measureed Capacitance (pF/m)')

# Element 2 - Cable Inductance
inductance_chart = SerialChart(item_geojson_related, name='Cable Inductance', categories_from='features', description='Cable Inductance')
inductance_chart.data.category_field = 'CableID'
inductance_chart.data.add_value_field('Measured Inductance (micro Henry/m)')


# Element 3 - Gauge
gauge = Gauge(webmap, name='Average Delta G in Visible Cable Network', layer=0, description='Average Delta G in Visible Cable Network')
gauge.data.value_type = 'statistic'
gauge.data.statistics = 'Average'
gauge.data.statistics_field = 'Delta_G'
gauge.gauge_options.shape = 'horseshoe'

 

Element 1&2 returns this error:

  File "C:/Users/Henrik/AppData/Roaming/JetBrains/PyCharmCE2020.2/scratches/scratch_4.py", line 23, in <module>
    capacitance_chart.data.category_field = 'CableID'
  File "D:\Anaconda\envs\agol_env\lib\site-packages\arcgis\apps\dashboard\_serialchart\_serial_chart.py", line 916, in category_field
    if self._field_type(value) == '<M8[ns]':
  File "D:\Anaconda\envs\agol_env\lib\site-packages\arcgis\apps\dashboard\_serialchart\_serial_chart.py", line 1048, in _field_type
    f_type = self._item.tables[0].query().sdf[field_name].dtype
IndexError: list index out of range

 

0 Kudos
PraktikantPraktikant
New Contributor

I also have the same issue like @Wirescan. When will this bug be fixed?

0 Kudos