How To Create a Pie Charts by using a JSON data?

hi,
I have a statistics dataset, which would be updated every hour. the format of the dataset is json, which like:

  { 'input_time' : '2019-01-02 10:30:00', 'num_a' : 100, 'num_b' : 300, 'num_c' : 200, 'num_d' : 500 }

I want to create a Pie Charts by using the data (num_a, num_b, num_c, num_d), unfortunately, Kibana could not do it.
my Kibana version is 6.4.2, any idea would be appreciate.
thanks.
Mark

Hello,
they way the data looks right now it would be rather difficult to build pie chart in Kibana.
What i would recommend is to split each document into 4 separate documents, like this:

  { 'input_time' : '2019-01-02 10:30:00', 'field_name': 'num_a', 'field_value': 100}
  { 'input_time' : '2019-01-02 10:30:00', 'field_name': 'num_b', 'field_value': 300}
  { 'input_time' : '2019-01-02 10:30:00', 'field_name': 'num_c', 'field_value': 200}
  { 'input_time' : '2019-01-02 10:30:00', 'field_name': 'num_d', 'field_value': 500}

Then you can do a pie chart with Split by Terms on the field_name field. Although, it depends on what you want to do with the data from the pie chart as the default one is a bit limited in what it can do. For any extra calculations and splits you will have to build your own piechart using Vega: https://www.elastic.co/guide/en/kibana/current/vega-graph.html

1 Like

thank you very much! it works, and I will try to use Vega soon.

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