# Creating bar graph with fields in JSON document

**URL:** https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856
**Category:** Kibana
**Created:** [December 14, 2019, 1:16am UTC](https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856 "2019-12-14T01:16:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![elasticuser3452](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@elasticuser3452](https://discuss.elastic.co/u/elasticuser3452)
#### Post date: [December 14, 2019, 1:16am UTC](https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856/1 "2019-12-14T01:16:16Z")

</div>

New to Kibana visualizations here...

I'm planning on publishing a JSON (once a day) that has populations of list of cities. Following is a sample JSON:

{  
"timestamp": "2019-10-10",  
"population\_stats": [  
{  
"city": "New York",  
"population": 8398748  
},  
{  
"city": "Los Angeles",  
"population": 3976322  
}  
]  
}

I'd like to setup cities in the X axis and population count in Y axis.

I can setup my X axis property (with Field aggregations) however I just can't get the populations reflect in the Y axis.

Using "count" in the Y axis always gives me 1 -- I guess this is because there's only one document for the given date range.

Is there a proper way to get the correct population count to display on the Y axis?

---

<div class="post-metadata">

### Author: ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)
#### Post date: [December 16, 2019, 10:24pm UTC](https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856/2 "2019-12-16T22:24:00Z")

</div>

Hey @elasticuser3452, I'd recommend denormalizing your data and inserting a document every day for every city. Kibana doesn't support "nested fields" and we're tracking the support for this here: [https://github.com/elastic/kibana/issues/1084](https://github.com/elastic/kibana/issues/1084)

---

<div class="post-metadata">

### Author: ![elasticuser3452](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@elasticuser3452](https://discuss.elastic.co/u/elasticuser3452)
#### Post date: [December 17, 2019, 4:34pm UTC](https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856/3 "2019-12-17T16:34:00Z")

</div>

Hi @Brandon_Kobel , thanks for the reply!

If I include a document for every city, everyday, I still don't think the population count in the JSON is going to be reflected correctly on Y-axis.

I think the only way to get the correct population count for say, for New York, for 2019-10-10 is to publish 8398748 JSONs to elastic. Just publishing one JSON with population stats for New York won't work.

So if I created something like below and published that, it'll continue to show 1 as the count in the Y-axis

{  
"date":"2019-10-10",  
"city":"New York",  
"population":8398748  
}

---

<div class="post-metadata">

### Author: ![elasticuser3452](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@elasticuser3452](https://discuss.elastic.co/u/elasticuser3452)
#### Post date: [December 18, 2019, 4:03pm UTC](https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856/4 "2019-12-18T16:03:43Z")

</div>

Figured this out. @Brandon_Kobel , you're correct! I can use separate JSONs and use "Sum" aggregation on Y-axis instead of "Count" aggregation.

---

<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: [January 15, 2020, 4:03pm UTC](https://discuss.elastic.co/t/creating-bar-graph-with-fields-in-json-document/211856/5 "2020-01-15T16:03:57Z")

</div>

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