# Limiting axis to only integers

**URL:** <https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296>\
**Category:** Kibana\
**Created:** [September 15, 2021, 2:31pm UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296 "2021-09-15T14:31:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Janujc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/janujc/32/77336_2.png) [@Janujc](https://discuss.elastic.co/u/Janujc)\
**Post date:** [September 15, 2021, 2:31pm UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/1 "2021-09-15T14:31:48Z")

</div>

Hello!  
I'm wondering if it is possible to limit the y-axis in different plots to show only integer values? We're showcasing the number of people doing different actions, therefore it really doesn't make sense to have decimal numbers on the plot. It usually just confuses people.

Example is shown below:  
 ![Screenshot_1](https://us1.discourse-cdn.com/elastic/original/3X/c/6/c62239b25157366f02c96b39df63465e6ff9ddd2.png)

Ideally, we would like to have only numbers 1 and 2 on the axis. What are my options to achieve that?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![nickofthyme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickofthyme/32/60032_2.png) [@nickofthyme](https://discuss.elastic.co/u/nickofthyme)\
**Post date:** [September 15, 2021, 5:25pm UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/2 "2021-09-15T17:25:46Z")

</div>

Where are you creating this chart above (i.e. Lens, aggs based, etc.)?

This is certainly possible with our charting library. I would like to see this globally applied for any count aggregations. Here is an issue pertaining to TSVB [@elastic/kibana#28614](https://github.com/elastic/kibana/issues/28614). I opened a new issue to set this as default in Lens here [@elastic/kibana#112324](https://github.com/elastic/kibana/issues/112324).

It looks like this is possible in Lens by setting the `value format` of the metric with `decimals` option set to `0`.

> Note there are some issue with setting `decimals` to `0`, see [@elastic/kibana#97100](https://github.com/elastic/kibana/issues/97100)

 ![Image 2021-09-15 at 11.56.44 AM](https://us1.discourse-cdn.com/elastic/original/3X/3/8/38bc92fad5a981b7da7c4401b920109e3b56b7a0.jpeg)

**-- UPDATED -- per @Janujc's comment below**  
Integer formatting is **only** used in `count` aggregations in _aggregation based_ visualizations. However this is **not** the case for other non-`count` aggregations, for these, floating-point tick values are used below a certain value.

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

---

<div class="post-metadata">

**Author:** ![Janujc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/janujc/32/77336_2.png) [@Janujc](https://discuss.elastic.co/u/Janujc)\
**Post date:** [September 16, 2021, 6:55am UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/3 "2021-09-16T06:55:05Z")

</div>

Thank you for your answer. I was able to solve this for my Lens charts. I was also able to solve it in TSVB with custom formatter and setting the "Format string" to 0.

The issue is still present in aggregation based charts. After one of the bars goes over the number 5, the y-axis scale is correct, as is shown on your picture. For lower numbers I believe the scale remains with decimal numbers. I still haven't found a way to solve this.

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

---

<div class="post-metadata">

**Author:** ![nickofthyme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickofthyme/32/60032_2.png) [@nickofthyme](https://discuss.elastic.co/u/nickofthyme)\
**Post date:** [September 16, 2021, 2:06pm UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/4 "2021-09-16T14:06:28Z")

</div>

Thanks for that clarification 👍, I updated my initial post to avoid confusion. This however is only the case for non-`count` aggregations. We can only determine the agg type is `count`, see code and gif below. It would be great to apply this if the type is a number with a pattern set to an integer.

> <https://github.com/elastic/kibana/blob/13074f129661ca7e3e5478055e0721d711e37723/src/plugins/vis_types/xy/public/config/get_axis.ts#L79>

![Screen Recording 2021-09-16 at 09.02.33 AM](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74734338e3cbc261a5948fd5c2a04e742c51273f.gif)

Yes TSVB won't work until [@elastic/kibana#28614](https://github.com/elastic/kibana/issues/28614) is closed.

> FYI this issue [@elastic/kibana#97100](https://github.com/elastic/kibana/issues/97100) is better for tracking change to tick formatting in Lens.

---

<div class="post-metadata">

**Author:** ![Janujc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/janujc/32/77336_2.png) [@Janujc](https://discuss.elastic.co/u/Janujc)\
**Post date:** [September 21, 2021, 11:49am UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/5 "2021-09-21T11:49:41Z")

</div>

Is **unique count** also considered a non-count aggregation? Because that is the problem I am facing. It would be nice if it worked as you suggested, especially in the case of **unique count** aggregation.

---

<div class="post-metadata">

**Author:** ![nickofthyme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickofthyme/32/60032_2.png) [@nickofthyme](https://discuss.elastic.co/u/nickofthyme)\
**Post date:** [September 21, 2021, 1:10pm UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/6 "2021-09-21T13:10:24Z")

</div>

> Is **unique count** also considered a non-count aggregation?

Unfortunately not currently, that is called `cardinality` agg not `count`. I am looking into adding this coercion for all counts and aggs of integer fields that are sensible, for example, percentile or standard deviation of an integer field may not make sense to have a strict integer axis.

---

<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:** [October 19, 2021, 1:10pm UTC](https://discuss.elastic.co/t/limiting-axis-to-only-integers/284296/7 "2021-10-19T13:10:34Z")

</div>

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