# A problem when applying a filter to heat maps

**URL:** https://discuss.elastic.co/t/a-problem-when-applying-a-filter-to-heat-maps/189762
**Category:** Kibana
**Created:** [July 10, 2019, 12:25pm UTC](https://discuss.elastic.co/t/a-problem-when-applying-a-filter-to-heat-maps/189762 "2019-07-10T12:25:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![M.alsioufi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m.alsioufi/32/52269_2.png) [@M.alsioufi](https://discuss.elastic.co/u/M.alsioufi)
#### Post date: [July 10, 2019, 12:25pm UTC](https://discuss.elastic.co/t/a-problem-when-applying-a-filter-to-heat-maps/189762/1 "2019-07-10T12:25:41Z")

</div>

I have a field of type date and default format `insertion_time`  
I wanted to create a heat map visualization in Kibana 6.5 where I can have and the `day_of_month` on x-Axis, the `hour` of the day on y-Axis and the color represents the `count`.  
So I had to create scripted fields that extract the hour and day\_of\_month as numbers and store them as sub fields under `insertion_time`.  
The scripts I used are:  
`doc['insertion_time'].date.dayOfMonth` for`insertion_time.day_of_month` field and  
`doc['recording_time'].date.hourOfDay` for`insertion_time.hour` field  
In the visualization settings, for X-axis Aggregation field I chose `Terms` the field is `insertion_time.day_of_month`, `31` values and the order is `Alphabetical` and `Descending`.  
However, whenever I apply a filter or try to split the chart on some fields the order breaks.

My questions are:

1. Is there any other way to handle the `hour` and `day_of_month` fields as date type? so Kibana can understand the way they should be ordered with?
2. How can I prevent the visualization from re-ordering the terms on the X and Y axis?
3. Are these issues solved in later versions of Kibana?
4. Is there any better visualization that I can use to show the data distribution I am interested in? Even if this requires installing some other Kibana plugin.

Thanks in advance..

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [July 10, 2019, 6:52pm UTC](https://discuss.elastic.co/t/a-problem-when-applying-a-filter-to-heat-maps/189762/2 "2019-07-10T18:52:39Z")

</div>

Use histogram instead of terms aggregation since the fields are numbers. This will give you the option to show all buckets.

![14%20PM](https://us1.discourse-cdn.com/elastic/original/3X/e/a/ea4ebe66db95ef0698c3472ef506bacc0bba3ede.png)

Looks like the ordering is still a little wonky when a filter is applied. I filed [https://github.com/elastic/kibana/issues/40790](https://github.com/elastic/kibana/issues/40790) to track.

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [July 10, 2019, 7:10pm UTC](https://discuss.elastic.co/t/a-problem-when-applying-a-filter-to-heat-maps/189762/3 "2019-07-10T19:10:10Z")

</div>

If you use histogram aggregation and set "show empty buckets" and configure "Extended bounds", then the heatmap will work as expected.

 ![52%20PM](https://us1.discourse-cdn.com/elastic/original/3X/7/7/77ea312258198b0b27b53659b1774f311f11646a.png)

---

<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: [August 7, 2019, 7:10pm UTC](https://discuss.elastic.co/t/a-problem-when-applying-a-filter-to-heat-maps/189762/4 "2019-08-07T19:10:16Z")

</div>

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