# How to create a line chart from object in array in ElasticSearch

**URL:** <https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759>\
**Category:** Kibana\
**Created:** [November 11, 2016, 6:15am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759 "2016-11-11T06:15:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![snrmukesh](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@snrmukesh](https://discuss.elastic.co/u/snrmukesh)\
**Post date:** [November 11, 2016, 6:15am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/1 "2016-11-11T06:15:59Z")

</div>

In ElasticSearch I have some sample data, against which I would like to visualize the line charts in Kibana 4. Samples in ElasticSearch look like this:

```
"_id": "AVhNy_dxcW7axK5BvIEO",
"timeStamp": "2016-11-11T05:39:10.5844951Z",
"analyticSource": [
                  {
                     "analyticId": "A",
                     "analyticUnit": "sec",
                     "analyticValue": 0.22743704915046692
                  },
                  {
                     "analyticId": "B",
                     "analyticUnit": "sec",
                     "analyticValue": 0.14946113526821136
                  }]

```

and another sample:

```
"_id": "AVhNxnjscW7axK5Bu-Tl",
"timeStamp": "2016-11-11T05:40:10.5954951Z",
"analyticSource": [
                  {
                     "analyticId": "A",
                     "analyticUnit": "sec",
                     "analyticValue": 0.20143736898899078
                  },
                  {
                     "analyticId": "B",
                     "analyticUnit": "sec",
                     "analyticValue": 0.09747125953435898
                  }]

```

For now Kibana just plot plot according to the column Id and in this case a single line chart is plotted for `analyticValue`. What I really want is to plot 2 line chart in Kibana for `A` and `B` against `timestamp`. Is there some kind of script(query) or something where I can say to kibana to seggregate the `analyticValue` according to `analyticId`?

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [November 11, 2016, 10:40pm UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/2 "2016-11-11T22:40:34Z")

</div>

The pattern of storing documents within other documents is commonly referred to as "nested documents", and unfortunately Kibana does not support it.

In order to visualize these documents in Kibana they will need to be indexed as their own events:

```json
{
  "timeStamp": "2016-11-11T05:39:10.5844951Z",
  "analyticId": "A",
  "analyticUnit": "sec",
  "analyticValue": 0.22743704915046692
},
{
  "timeStamp": "2016-11-11T05:39:10.5844951Z",
  "analyticId": "B",
  "analyticUnit": "sec",
  "analyticValue": 0.14946113526821136
}

```

---

<div class="post-metadata">

**Author:** ![snrmukesh](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@snrmukesh](https://discuss.elastic.co/u/snrmukesh)\
**Post date:** [November 14, 2016, 3:39am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/3 "2016-11-14T03:39:11Z")

</div>

Make sense to me if its not supported, I thought there might be some kind of hack to flatten this objects to array. Do you know if any near future kibana will support this.

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [November 14, 2016, 5:12am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/4 "2016-11-14T05:12:22Z")

</div>

I wouldn't count on it

---

<div class="post-metadata">

**Author:** ![snrmukesh](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@snrmukesh](https://discuss.elastic.co/u/snrmukesh)\
**Post date:** [November 14, 2016, 6:45am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/5 "2016-11-14T06:45:30Z")

</div>

Hi, Now I created the flat mapping as recommended by you, but can't able to filter `analyticValue` based upon `analyticId`. In Y axis I can choose analyticValue but couldn't find filter option there. Could you shed some light on this.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [November 14, 2016, 8:56am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/6 "2016-11-14T08:56:19Z")

</div>

Not sure if I understand you correctly, but filters should be applied in the filter bar not on the metrics.

If you type something like `analyticId: B` in your query bar it should only select that data.

Or you could add another visualization, like pie and split it by analyticsId. you would get a pie chart with A, B, C (the most common ids).  
Now if you put this pie chart on the same dashboard you have your chart where you plot analyticsValue, you can click a slice and it will apply filter so your value chart will get instantly updated with just those values.

---

<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:** [December 12, 2016, 8:56am UTC](https://discuss.elastic.co/t/how-to-create-a-line-chart-from-object-in-array-in-elasticsearch/65759/7 "2016-12-12T08:56:36Z")

</div>

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