# Line graph visualization bug?

**URL:** <https://discuss.elastic.co/t/line-graph-visualization-bug/49075>\
**Category:** Kibana\
**Created:** [May 3, 2016, 3:22pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075 "2016-05-03T15:22:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fran\_Fabrizio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fran_fabrizio/32/9533_2.png) [@Fran\_Fabrizio](https://discuss.elastic.co/u/Fran_Fabrizio)\
**Post date:** [May 3, 2016, 3:22pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/1 "2016-05-03T15:22:58Z")

</div>

So, I managed to create this beauty...

[![](https://dl.dropboxusercontent.com/s/ah3cz05sy0doujz/Screenshot%202016-05-02%2017.00.39.png?dl=0) ](https://dl.dropboxusercontent.com/s/ah3cz05sy0doujz/Screenshot%202016-05-02%2017.00.39.png?dl=0)

(Sorry I cut off the legend - the individual lines are for different years - explained below).

I have documents with field user\_id and then I have scripted fields year and month\_of\_year which are calculated off of @timestamp.

I defined a line graph where I first did a split lines on term year and then a sub-bucket x-axis on term month\_of\_year. In both cases I ordered by Term Ascending (with 6 for the year, since my data is 2011-2016, and 12 for the month\_of\_year). The y-axis is unique count of user\_id.

As you can see, something is goofy. 🙂 Specifically, it seems to have had trouble sorting month\_of\_year in ascending order. Is this a bug, or did I just configure something incorrectly?

FYI, my goal for this graph is to have a line for each year showing number of unique users by month - for easy year-over-year comparison.

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [May 4, 2016, 12:56pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/2 "2016-05-04T12:56:17Z")

</div>

Hi, can you share the following information please?

- Versions of Kibana and Elasticsearch.
- Definitions of the `year` and `month_of_year`scripted fields. Specifically, what you've entered into the Script text box when creating each scripted field.
- The response from Elasticsearch for this visualization. To get this, open the visualization on the Visualize page, then click the little ^ button below the chart. This will pop open what is called the spy panel. In the spy panel, click the Response button. This will show the Elasticsearch response for this visualization.

---

<div class="post-metadata">

**Author:** ![Fran\_Fabrizio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fran_fabrizio/32/9533_2.png) [@Fran\_Fabrizio](https://discuss.elastic.co/u/Fran_Fabrizio)\
**Post date:** [May 4, 2016, 2:11pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/3 "2016-05-04T14:11:19Z")

</div>

Sure, sorry I omitted that previously. Kibana 4.4.2, Elasticsearch 2.2.0.

year is defined as doc['@timestamp'].getYear()  
month\_of\_year is defined as doc['@timestamp'].getMonth()

The response exceeds the forum's character limit, but can be viewed here: [https://www.dropbox.com/s/6paqrl41ymr9lew/elasticsearch-response.txt?dl=0](https://www.dropbox.com/s/6paqrl41ymr9lew/elasticsearch-response.txt?dl=0)

---

<div class="post-metadata">

**Author:** ![Fran\_Fabrizio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fran_fabrizio/32/9533_2.png) [@Fran\_Fabrizio](https://discuss.elastic.co/u/Fran_Fabrizio)\
**Post date:** [May 4, 2016, 9:52pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/4 "2016-05-04T21:52:04Z")

</div>

Update: same behavior observed after upgrading to ES 2.3.2 and Kibana 4.5.

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [May 4, 2016, 9:56pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/5 "2016-05-04T21:56:44Z")

</div>

Hi,

I was able to reproduce this. You simply need to reorder the aggregations to fix this 🙂

So currently you are seeing something like this (the thing to note is that the Split Lines by year aggregation is happening before the X-Axis by month\_of\_year aggregation) :

 ![](https://us1.discourse-cdn.com/elastic/original/2X/8/8e5ad519e76ad28dfd60ac74fad052dda168afc3.png)

Just click the little "Increase Priority" arrow next to the X-Axis by month\_of\_year aggregation:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/27e5b016a584823f569fc96e85572295126fb300.png)

Then, if you re-render the visualization, you should get the right ordering of the months on the X axis:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/1/1abd7979bf6b01997c6e2aec3f22c12af93fb206.png)

---

<div class="post-metadata">

**Author:** ![Fran\_Fabrizio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fran_fabrizio/32/9533_2.png) [@Fran\_Fabrizio](https://discuss.elastic.co/u/Fran_Fabrizio)\
**Post date:** [May 5, 2016, 2:18am UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/6 "2016-05-05T02:18:45Z")

</div>

Thanks, that does solve this problem. Unfortunately, it leads me to  
another problem, where my data values were changing unexpectedly when I add  
buckets, which I describe in a separate post here:

> [@Confused about interaction between unique count and buckets](https://discuss.elastic.co/t/confused-about-interaction-between-unique-count-and-buckets/49243/1):
>
> Let's say I set my time range to be 2013-01-01 00:00:00.000 to 2013-01-31 23:59:59.999 (entire month of January 2013). Then I do a line graph visualization and keep the default y-axis setup which is a count of \_all documents in my index in that time range, it produces 1,565 hits. (just a dot at 1,565, since I haven't defined an x-axis). One of the fields in my documents is user\_id. If I then change the y-axis to do a Count of user\_id in that same time period, I get 1,565 hits. So far, nothi…

Thanks again. I'm glad that reordering the buckets solved the graphing  
bug, at least!

---

<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 6, 2017, 1:54pm UTC](https://discuss.elastic.co/t/line-graph-visualization-bug/49075/7 "2017-07-06T13:54:21Z")

</div>


