# How to fix a rule on x axis using time

**URL:** <https://discuss.elastic.co/t/how-to-fix-a-rule-on-x-axis-using-time/266285>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 4, 2021, 8:08pm UTC](https://discuss.elastic.co/t/how-to-fix-a-rule-on-x-axis-using-time/266285 "2021-03-04T20:08:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bab/32/86201_2.png) [@bab](https://discuss.elastic.co/u/bab)\
**Post date:** [March 4, 2021, 8:08pm UTC](https://discuss.elastic.co/t/how-to-fix-a-rule-on-x-axis-using-time/266285/1 "2021-03-04T20:08:14Z")

</div>

hello all,

I am trying to fix a fixed line to the x acse where time = 15:30 so that I can notice the bars that took longer than 15:30. what have i done wrong?

tha is my Code:

```
   {
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "title": "Event counts from all indexes",
  "layer": [
    {
      "data": {
        "url": {
          "%context%": true,
          "%timefield%": "Date",
          "index": "index_tev_test",
          "body": {"size": 300, "_source": ["Date", "Start", "COMD Belege"]}
        },
        "format": {"property": "hits.hits"}
      },
      "mark": "bar",
      "encoding": {
        "y": {
          "field": "_source.Date",
          "type": "n",
          "sort": 0,
          "axis": {"title": "Datum "}
        },
        "x": {
          "field": "_source.Start",
          "type": "nominal",
          "axis": {"title": "Start to COMD Belege"}
        },
        "x2": {"field": "_source.COMD Belege", "type": "n"},
        "color": {"value": "green"}
      }
    },
    {
      "data": {"values": {"foo": "bar"}},
      "transform": [
      //{"calculate": "field": "COMD Belege", "expr": "hours(datum.COMD Beleg)"}
      {"calculate": "time(1530)", "as": "now_field"}
      //{"calculate": [{"field": "hour", "expr": "hours(datum.date)"}],
      
      ],
      "mark": "rule",
      "encoding": {
        "x": {"aggregate": "mean", "type": "o", "field": "now_field"},
        "color": {"value": "red"},
        "size": {"value": 5}
      }
    }
  ]
}

```

the result is 🙁 :

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

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [March 5, 2021, 1:13pm UTC](https://discuss.elastic.co/t/how-to-fix-a-rule-on-x-axis-using-time/266285/2 "2021-03-05T13:13:15Z")

</div>

Can you try setting it to

```auto
"value": 1331321

```

where you replace 1331321 with the equivalent for 15:30 instead of doing all that calculate stuff?  
You would have to remove the aggregate, the type and the field properties.

---

<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:** [April 2, 2021, 1:13pm UTC](https://discuss.elastic.co/t/how-to-fix-a-rule-on-x-axis-using-time/266285/3 "2021-04-02T13:13:22Z")

</div>

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