Select to view content in your preferred language

ArcGIS Hub - JSON Stacked Bar Chart

1085
1
Jump to solution
04-29-2020 12:38 PM
HaleyDockray
Emerging Contributor

I am brand new to JSON so I may be missing something super simple here. I am struggling with my code that is supposed to generate a stacked bar chart with three different data sources. I want the x-axis to show the dates and the y-axis to show the count for each date (I have excluded the url and renamed the datasets):

{
  "type": "bar",
  "datasets": [
    {
      "url": "Dataset1",
      "name": "Dataset1",
      "query": {
       
        "orderByFields": "FID_count DESC",
        "groupByFieldsForStatistics": "Date",
        "outStatistics": [{
          "statisticType": "count",
          "onStatisticField": "FID",
          "outStatisticFieldName": "FID_count"
        }]
      },
      "join": "Date"
    },
    {
          "url": "Dataset2",
          "name": "Dataset2",
          "query": {
           
            "orderByFields": "FID_count DESC",
            "groupByFieldsForStatistics": "Date_",
            "outStatistics": [{
              "statisticType": "count",
              "onStatisticField": "FID",
              "outStatisticFieldName": "FID_count"
            }]
          },
          "join": "Date_"
    },
    {
              "url": "Dataset3",
              "name": "Dataset3",
              "query": {
               
                "orderByFields": "FID_count DESC",
                "groupByFieldsForStatistics": "Date",
                "outStatistics": [{
                  "statisticType": "count",
                  "onStatisticField": "FID",
                  "outStatisticFieldName": "FID_count"
                }]
              },
              "join": "Date"
    }
    ],
      "series": [
        {
          "category": {"field": "Date", "label": "Date"},
          "value": { "field": "FID_count", "label": "Dataset1"},
          "source": "Dataset1",
          "stack": true
        },
        {
          "category": {"field": "Date_", "label": "Date"},
             "value": { "field": "FID_count", "label": "Dataset2"},
             "source": "Dataset2",
          "stack": true
        },
        {
          "category": {"field": "Date", "label": "Date"},
             "value": { "field": "FID_count", "label": "Dataset3"},
             "source": "Dataset3",
          "stack": true
        }
      ]
}

No matter what adjustments I make to the code it never seems to work and I always get "There was an error in chart generation".

I feel like this should be super easy but I am about to bang my head against the wall!

0 Kudos
1 Solution

Accepted Solutions
HaleyDockray
Emerging Contributor

I actually got this figured out by posting on another site...

The issue was the join. I needed to use the same value for each join function.

View solution in original post

1 Reply
HaleyDockray
Emerging Contributor

I actually got this figured out by posting on another site...

The issue was the join. I needed to use the same value for each join function.