Content Alert
We've posted a post over on the ArcGIS Blog - head on over to read about configuring dynamic charts and statistics and see some examples.
If you've added some charts and stats already, drop your site links in GeoNet and show them off!
Thanks for the sample code. I am trying to implement this on my hub site page and I have copied the sample code and replaced the values with my data. I have also validated it in json validator. I get an error message saying there was an error in chart generation. I have 3 columns of data. Year, Rental Homes, Ownership Homes. I would like Year to chart across the X and the number of homes by type to chart on the y-axis. here is my code. Why is it not working? Thanks!
{ "type": "grouped", "tooltip": { "title": "{Year}", "content": "{Ownership_Homes} Ownership Homes | {Rental_Homes} Rental Homes" }, "datasets": [{ "url": "https://services1.arcgis.com/KVHZNprt62ZdIujN/arcgis/rest/services/Affordable_Housing/FeatureServer" }], "series": [{ "category": { "field": "Year", "label": "Year" }, "value": { "field": "Ownership_Homes", "label": "Type" } }, { "category": { "field": "Year", "label": "Year" }, "value": { "field": "Rental_Homes", "label": "Type " } }]}
Nice find of the old post!
We have launched an updated version of the charting engine since this post.
I took a crack at your chart....the biggest thing that was tricky was re-casting your numeric data from a string to a number field. Try this out in the JSON mode of a new chart card! (You may have to drag a new card to your site to get an updated editor)
I also had to use the desired layer from your feature server (added a `/0` to the end of your URL)
We have a tool that shows a few examples here - ember-cli-cedar
```
{ "type": "line", "datasets": [ { "url": "https://services1.arcgis.com/KVHZNprt62ZdIujN/arcgis/rest/services/Affordable_Housing/FeatureServer/0", "query": { "groupByFieldsForStatistics": "Year", "outStatistics": [ { "statisticType": "sum", "onStatisticField": "CAST(Ownership_Homes as float)", "outStatisticFieldName": "Ownership_Homes_Sum" }, { "statisticType": "sum", "onStatisticField": "CAST(Rental_Homes as float)", "outStatisticFieldName": "Rental_Homes_Sum" } ], "orderByFields": "Year ASC", "sqlFormat": "standard" } } ], "series": [ { "category": { "field": "Year", "label": "Year" }, "group": true, "value": { "field": "Ownership_Homes_Sum", "label": "Ownership_Homes_Sum" } }, { "category": { "field": "Year", "label": "Year" }, "value": { "field": "Rental_Homes_Sum", "label": "Rental_Homes_Sum" }, "group": true } ]}
Thank you so much!!!!! The chart is generating on the hub site.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Nový zde? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.