# Vega HeatMap

**URL:** <https://discuss.elastic.co/t/vega-heatmap/161528>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [December 19, 2018, 1:33pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528 "2018-12-19T13:33:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_CC](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_cc/32/47241_2.png) [@Mike\_CC](https://discuss.elastic.co/u/Mike_CC)\
**Post date:** [December 19, 2018, 1:33pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528/1 "2018-12-19T13:33:24Z")

</div>

Hi everyone,

I'm trying to build a heatmap in Vega. I can't build it in the normal heatmap visualization because I need each cell to be a ratio.

I have 3 fields, X from 0 to 9, Y from 0 to 9 and Z with values 0 or 1.

My goal is to build a heat map where the value of each cell is the ratio of all [X,Y] where Z==1 divided by all [X,Y].

So I do the following query: "GET logstash-_/\_search?q=X:0 AND Y:0 AND Z:1" and the hits.total is the numerator value I'm looking for. And if I do this one: "GET logstash-_/\_search?q=X:0 AND Y:0" I get the denominator.

Is there a way of using the ratio of all the 100 combinations I get to build the heatmap?

Is there a simple example of building a heatmap with vega that I could follow? The only one I found is a bit complicated.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [December 19, 2018, 4:33pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528/2 "2018-12-19T16:33:18Z")

</div>

@nyuriks ...can u plz help here?

Thanks  
Rashmi

---

<div class="post-metadata">

**Author:** ![Mike\_CC](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_cc/32/47241_2.png) [@Mike\_CC](https://discuss.elastic.co/u/Mike_CC)\
**Post date:** [December 20, 2018, 1:08pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528/3 "2018-12-20T13:08:37Z")

</div>

Hi again,

I found a simple example I could follow:

> **[Annual Weather Heatmap](https://vega.github.io/vega-lite/examples/rect_heatmap_weather.html)**
>
> Vega-Lite - a high-level grammar for statistical graphics. Vega-Lite provides a higher-level grammar for visual analysis, comparable to ggplot or Tableau, that generates complete Vega specifications. Vega-Lite specifications consist of simple...

But I still encounter the same problem, how do I use the ratio between the results of two queries to color the cells.

Thank you!

Best,

Michael

---

<div class="post-metadata">

**Author:** ![danders](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@danders](https://discuss.elastic.co/u/danders)\
**Post date:** [January 15, 2019, 4:55pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528/4 "2019-01-15T16:55:00Z")

</div>

Hi all,

I am interested in doing a very similar thing in a Kibana Heatmap. Is there no way to be able to perform such a calculation?

Many thanks in advance.

David

---

<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:** [February 12, 2019, 4:55pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528/5 "2019-02-12T16:55:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)\
**Post date:** [September 9, 2019, 5:15pm UTC](https://discuss.elastic.co/t/vega-heatmap/161528/6 "2019-09-09T17:15:01Z")

</div>

@Mike_CC if your entire elasticsearch index contains just 200 documents (x-10 \* y-10 \* z-2), you can just load them all (i.e. all documents that contain x,y, and z fields), and then use the same approach as shown in [https://vega.github.io/vega/examples/heatmap/](https://vega.github.io/vega/examples/heatmap/) . If your data is much bigger, you need to construct your query in such a way as to produce those 200 documents.
