Add Slices to Hub Pie Chart

819
4
Jump to solution
01-18-2022 05:59 PM
pmccord
New Contributor III

I'm creating a pie chart on an ArcGIS Hub page. There are six categories that I want to display in my pie chart, but when I build the chart, three categories are grouped together in an Other category.

Here is the Excel spreadsheet that I've uploaded to AGOL to create the feature layer which feeds the pie chart:

pmccord_0-1642557118870.png

However, this is how the chart renders when I use Material as my Category and Length as my Value for the pie chart:

pmccord_2-1642557242107.png

I've also tried using the JSON option to specify my chart definition as follows:

 

{
  "type": "pie",
  "datasets": [
    {
      "name": "dataset1",
      "query": {
        "orderByFields": "Length__miles__sum DESC",
        "groupByFieldsForStatistics": "Material",
        "outStatistics": [
          {
            "statisticType": "sum",
            "onStatisticField": "Length__miles_",
            "outStatisticFieldName": "Length__miles__sum"
          }
        ]
      },
      "url": "URL WOULD BE HERE, BUT I REMOVED"
    }
  ],
  "series": [
    {
      "source": "dataset1",
      "category": {
        "field": "Material",
        "label": "Material"
      },
      "value": {
        "field": "Length__miles__sum",
        "label": "Length (miles)"
      }
    }
  ],
  "style": {
    "padding": {
      "top": 30,
      "bottom": 10
    },
    "pie": {
      "expand": 0
    },
"colors": [
      "#484C70",
      "#93B7BE",
      "#E0CA3C",
      "#A799B7",
      "#048A81",
      "#CD8987"
    ]
  }
}

 

 

However, I couldn't find any documentation that specified how I might add additional slices to my pie chart. If anyone has experience doing this, I'd greatly appreciate some help. Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KlaraSchmitt
Esri Contributor

Hello,

I asked a colleague for insight on your issue and he said you can add:

"overrides": {
"groupPercent": 2 <--- whatever percentage it is
}

"About groupPercent, if there is more than one slice whose percentage of the pie is less than this number, those slices will be grouped together into one slice. This is the "other" slice. It will always be the last slice in a pie."

At line 49, put a comma after the closing bracket, hit return, then add the overrides object. He says you'll have to figure out the actual percentage you need as it's currently defaulting to 5%.

View solution in original post

4 Replies
KlaraSchmitt
Esri Contributor

Hello,

I asked a colleague for insight on your issue and he said you can add:

"overrides": {
"groupPercent": 2 <--- whatever percentage it is
}

"About groupPercent, if there is more than one slice whose percentage of the pie is less than this number, those slices will be grouped together into one slice. This is the "other" slice. It will always be the last slice in a pie."

At line 49, put a comma after the closing bracket, hit return, then add the overrides object. He says you'll have to figure out the actual percentage you need as it's currently defaulting to 5%.

pmccord
New Contributor III

Thank you Klara! Your solution worked perfectly!

Is there any documentation that you or your colleague can point me to that has some of this information because I wasn't able to find it when I was initially tackling this. There are a few additional things I'm hoping to do to customize my charts... like removing the border that currently exists around the Chart frame (maybe that's not possible, but I'd like to try).

0 Kudos
KlaraSchmitt
Esri Contributor

Admittedly, I'm a little over my head when it comes to chart JSON. I'm not sure we have a lot of formal documentation, but there is a sandbox here: https://esri.github.io/cedar/, which links you to the cedar library. I don't know if that really covers the type of documentation you need. The underlying charting technology is https://docs.amcharts.com/3/javascriptcharts, but there will be limitations on what can and cannot be overwritten.

pmccord
New Contributor III

No problem. Thanks for the additional resources and for the solution!

0 Kudos