Creating bar graph with fields in JSON document

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?

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

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
}

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

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