# Heatmap sorting working in Visualisation Editor but not in Dashboard

**URL:** <https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814>\
**Category:** Kibana\
**Created:** [May 24, 2021, 11:04am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814 "2021-05-24T11:04:15Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [May 24, 2021, 11:04am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/1 "2021-05-24T11:04:16Z")

</div>

Hello

We want to create event dashboard, which would shown, how many log events came in Day of Week and Hour of day.  
We have created dynamic fields for DayOfWeek and HourOfDay (number format). Which are then used in heatmap with histogram aggregation.

This is how the visualization looks in editor:

 ![Weeklydistribution-Visualization](https://us1.discourse-cdn.com/elastic/original/3X/3/5/35865fc73d93895252a0ce6671706d3988eccae5.jpeg)

And this is how it looks like, when imported to dashboard:

 ![Weeklydistribution-Dashboard](https://us1.discourse-cdn.com/elastic/original/3X/f/0/f0792e13bf92892fa9f082f9305611edec3ba048.jpeg)

Note how the heatmap is being reordered in dashboard and it looks correctly in editor. I also tried to do heatmap with term aggregation, where I tried to sort it alphabetically, but the result is the same.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 25, 2021, 12:03am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/2 "2021-05-25T00:03:16Z")

</div>

Numbers in legend are also different. e.g. (0-700) vs. (0-1.2)  
Are you sure this is the same visualisation?

---

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [May 27, 2021, 7:36am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/3 "2021-05-27T07:36:08Z")

</div>

Hello,

The numbers are different, because there is filter applied in the dashboard. I will test the visualization with same filter, to see if it is same behavior.

Nevertheless, I thought that the "sort" settings handles it with no regards to a filter.

---

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [May 27, 2021, 3:20pm UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/4 "2021-05-27T15:20:35Z")

</div>

OK,

so I tested it a little bit, and it seems to be dependent on the number of records displayed, when there is enough documents, it sorts as defined, but when there is lower number of documents (time period shorter, or filter applied) then it doesnt have propper order

Few documents:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/e/ae527b8e33307d8ced0d2e706fbff6459bdb4e1d.png)

Many documents:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/2/b27c3aa1ea511a9cf8de705be45ed772d5a1ebbf.png)

It starts to fall apart somewhere between 3000 - 4500 hits, where after those 4500, the order is OK.

If it helps, here is my url:

```
http://<IP ADDRESS>:9662/app/visualize#/edit/ace09d10-b4af-11eb-a1ae-35831924ac87?_g=(filters:!(),query:(language:kuery,query:'prometheus.labels.ucsm%20:%20dcpmuc*'),refreshInterval:(pause:!t,value:0),time:(from:now-13d,to:now))&_a=(filters:!(),linked:!f,query:(language:kuery,query:''),uiState:(),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'2',params:(field:DayOfWeek,missingBucket:!f,missingBucketLabel:Missing,order:asc,orderBy:_key,otherBucket:!f,otherBucketLabel:Other,size:8),schema:segment,type:terms),(enabled:!t,id:'3',params:(exclude:!(''),field:HourOfDay,include:!(''),missingBucket:!f,missingBucketLabel:Missing,order:asc,orderBy:_key,otherBucket:!t,otherBucketLabel:Other,size:25),schema:group,type:terms)),params:(addLegend:!t,addTooltip:!t,colorSchema:'Green%20to%20Red',colorsNumber:10,colorsRange:!((from:0,to:1),(from:1,to:400),(from:400,to:799),(from:799,to:1198),(from:1198,to:1597)),enableHover:!f,invertColors:!f,legendPosition:top,percentageMode:!f,setColorRange:!f,times:!(),type:heatmap,valueAxes:!((id:ValueAxis-1,labels:(color:black,overwriteColor:!f,rotate:0,show:!t),scale:(defaultYExtents:!f,type:linear),show:!f,type:value))),title:'Event%20Distribution',type:heatmap))
```

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 28, 2021, 12:13am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/5 "2021-05-28T00:13:19Z")

</div>

Still not sure what is the issue raised.  
Can you say what is the expected result and why?

---

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [May 28, 2021, 11:18am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/6 "2021-05-28T11:18:15Z")

</div>

So, simply said, I want to have dashboards, with ordered buckets, no matter filters, time range or number of documents.

Problem I have, is that buckets in visualizations are not ordered alphabetically (term aggregation) nor numerically (histogram) when I dont have enough documents in those buckets - at least that is my observation

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 30, 2021, 11:09pm UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/7 "2021-05-30T23:09:57Z")

</div>

Please demonstrate that.

> [@mkostros](#):
>
> Problem I have, is that buckets in visualizations are not ordered alphabetically (term aggregation) nor numerically (histogram) when I dont have enough documents in those buckets - at least that is my observation

Thanks

---

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [May 31, 2021, 7:27am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/8 "2021-05-31T07:27:06Z")

</div>

Hello,

sorry, maybe I didn't make myself clear enough 🙂

Here is dashboard I made with a lot of documents (with light filter as well):

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/9/f9e11603f487fb1f2afc9d6fde725a1248dbf7ed.png)

Here is dashboard when I apply filter to reduce count of documents significantly:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a996a09056db24111a15767a8678a8dfc994164b.png)

Here is detail of the visualization (how I created it):

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/e/cee213e86a0a83986dcaa3dfd46a2ef3055546f5.png)

Maybe I should also note, that these fields are scripted in kibana as follows:

```auto
HourOfDay : LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['DateCreated'].value.millis), ZoneId.of('CET')).getHour()

DayOfWeek: doc['DateCreated'].value.dayOfWeek

```

If anything more is needed, just ask 🙂

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [June 1, 2021, 1:23am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/9 "2021-06-01T01:23:31Z")

</div>

And what is the issue?

---

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [June 1, 2021, 7:49am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/10 "2021-06-01T07:49:24Z")

</div>

> And what is the issue?

Sorting of heatmap buckets not working.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [June 1, 2021, 10:29pm UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/11 "2021-06-01T22:29:43Z")

</div>

Sorry, Maybe someone else will understand.  
Good luck

---

<div class="post-metadata">

**Author:** ![mkostros](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@mkostros](https://discuss.elastic.co/u/mkostros)\
**Post date:** [June 2, 2021, 7:37am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/12 "2021-06-02T07:37:25Z")

</div>

I dont know how to write it probably.

How I need Y-axis buckets ordered:  
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24

How I have Y-axis bucktes ordered:  
2,3,5,9,10,11,12,13,14,15,16,17,19,21,22,4,6,7,8,18,20,23,1,0

I've defined the ordering as alphabetical - but what you see above is not alphabetical nor numercial - it is random. That is why I think it is a bug.

---

<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:** [June 30, 2021, 7:38am UTC](https://discuss.elastic.co/t/heatmap-sorting-working-in-visualisation-editor-but-not-in-dashboard/273814/13 "2021-06-30T07:38:14Z")

</div>

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