# KIbana - pie chart splitting by value of fields

**URL:** <https://discuss.elastic.co/t/kibana-pie-chart-splitting-by-value-of-fields/236081>\
**Category:** Kibana\
**Created:** [June 7, 2020, 9:15am UTC](https://discuss.elastic.co/t/kibana-pie-chart-splitting-by-value-of-fields/236081 "2020-06-07T09:15:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stg7](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@stg7](https://discuss.elastic.co/u/stg7)\
**Post date:** [June 7, 2020, 9:15am UTC](https://discuss.elastic.co/t/kibana-pie-chart-splitting-by-value-of-fields/236081/1 "2020-06-07T09:15:22Z")

</div>

This sounds quite stupid.

I usually got data from json like  
{ "name":"john","category":"A"}  
{ "name":"paul","category":"B"}  
{ "name":"henry","category":"A"}  
{"name:"jane","category":"C"}  
I easily manage to get the percentage of category A and percentage of category B in a pie chart with an index made of two fields : name and category.

My problem is that I now have a json that comes with the percentage being already processed. something like :  
{"categoryA":50}  
{"categoryB":25}  
{"categoryC":25}  
My index is therefore made of 3 fields : categoryA, category B, categoryC  
How do I make a pie chart that will take into account the categories value?

I should be so simple and I don't see how.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [June 11, 2020, 3:14pm UTC](https://discuss.elastic.co/t/kibana-pie-chart-splitting-by-value-of-fields/236081/2 "2020-06-11T15:14:27Z")

</div>

You can use `top hits` metric to use a value from the document as the pie slice percentage

In the screen shot below, the pie slice percentage is from the `hour_of_day` field for the first matching document for each split.

 ![Screen Shot 2020-06-11 at 9.10.44 AM](https://us1.discourse-cdn.com/elastic/original/3X/1/e/1ee7d1426dc6e781dc1631ca1b653acc10e2ee6e.png) .

---

<div class="post-metadata">

**Author:** ![stg7](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@stg7](https://discuss.elastic.co/u/stg7)\
**Post date:** [June 11, 2020, 4:12pm UTC](https://discuss.elastic.co/t/kibana-pie-chart-splitting-by-value-of-fields/236081/3 "2020-06-11T16:12:19Z")

</div>

That means i would have to change a bit the structure of the json I receive, so that I get something like this :  
{"category":"A","percentage":50}  
{"category":"B","percentage":25}  
{"category":"C","percentage":25}

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 9, 2020, 4:12pm UTC](https://discuss.elastic.co/t/kibana-pie-chart-splitting-by-value-of-fields/236081/4 "2020-07-09T16:12:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
