# Vegalite graph scale according to Min,Max of the value

**URL:** https://discuss.elastic.co/t/vegalite-graph-scale-according-to-min-max-of-the-value/271246
**Category:** Kibana
**Tags:** vega
**Created:** [April 26, 2021, 11:03am UTC](https://discuss.elastic.co/t/vegalite-graph-scale-according-to-min-max-of-the-value/271246 "2021-04-26T11:03:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![usman1](https://avatars.discourse-cdn.com/v4/letter/u/c67d28/32.png) [@usman1](https://discuss.elastic.co/u/usman1)
#### Post date: [April 26, 2021, 11:03am UTC](https://discuss.elastic.co/t/vegalite-graph-scale-according-to-min-max-of-the-value/271246/1 "2021-04-26T11:03:58Z")

</div>

I have plotted a graph using Vegalite visualization in Kibana as shown below:

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

As it can be seen, Y-axis scale starts from 0 and goes upto 450. Though it covers the Maximum and Min values of Y variable but not efficiently. I want the scale of the graph to be between [Min-10, Max+10] so that granular details can be seen which we cannot see at the moment and a straight line is being shown.

Following is the code responsible for defining axis:

```auto
    "repeat": {
      "layer": ["Avg_Wght", "Set_Point"]
    },

      "spec": {
    mark: "line",
    encoding: {
      x: {field: "time", "type": "temporal"},
      y: {
        "field": {"repeat": "layer"}
        "aggregate": "mean"
       
      }
      "color": {
        "datum": {"repeat": "layer"},
        "type": "nominal"
      }
    }
    } 

```

> If I use "scale": {"domain": [400, 420]}, it does restrict it as per my needs but it is not dynamic for all the records.

---

<div class="post-metadata">

### Author: ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)
#### Post date: [April 26, 2021, 1:58pm UTC](https://discuss.elastic.co/t/vegalite-graph-scale-according-to-min-max-of-the-value/271246/2 "2021-04-26T13:58:29Z")

</div>

i think you can use `zero: false` on the y scale, like in this example: [Connected Scatterplot (Lines with Custom Paths) | Vega-Lite](https://vega.github.io/vega-lite/examples/connected_scatterplot.html)

---

<div class="post-metadata">

### Author: ![usman1](https://avatars.discourse-cdn.com/v4/letter/u/c67d28/32.png) [@usman1](https://discuss.elastic.co/u/usman1)
#### Post date: [April 26, 2021, 2:00pm UTC](https://discuss.elastic.co/t/vegalite-graph-scale-according-to-min-max-of-the-value/271246/3 "2021-04-26T14:00:53Z")

</div>

@wylie It worked, thanks.

---

<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: [May 24, 2021, 2:01pm UTC](https://discuss.elastic.co/t/vegalite-graph-scale-according-to-min-max-of-the-value/271246/4 "2021-05-24T14:01:24Z")

</div>

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