# How to set on x axis an time range by hour?

**URL:** https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257
**Category:** Kibana
**Created:** [May 10, 2017, 1:58pm UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257 "2017-05-10T13:58:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![erion](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@erion](https://discuss.elastic.co/u/erion)
#### Post date: [May 10, 2017, 1:58pm UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/1 "2017-05-10T13:58:09Z")

</div>

I want to set in interval by hour on axis x and a time range that count one month. i want to see two lines that show log in two different days in determinated hours .

 ![](https://us1.discourse-cdn.com/elastic/original/3X/d/f/df9a0aa6a671797b8aa50f783bc290237d62e913.png).  
this an example: on x axis an interval by hour but i want to set the time on line not in the time piker. Because there are a lot of free space and i want to see line up line. one line = one day, y axis = count and x axis range time from 14:00 to 21:00.  
thanks for your answere

---

<div class="post-metadata">

### Author: ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)
#### Post date: [May 10, 2017, 2:35pm UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/2 "2017-05-10T14:35:16Z")

</div>

hi @erion,

That's an interesting problem.

I would create two scripted fields that gets the hour for those two days as a numerical value.

That way you chart will not be bound by the time-picker (which uses the default date-field from your index pattern).

Then you can plot two lines, one for each of these days.

To write a scripted-field, see following links:

- creating a scripted field in Kibana: [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)
- Painless language syntax. The relevant part s the Date-syntax. You can use it to get the hour-of-day: [https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html#modules-scripting-painless-dates](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html#modules-scripting-painless-dates)

---

<div class="post-metadata">

### Author: ![erion](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@erion](https://discuss.elastic.co/u/erion)
#### Post date: [May 12, 2017, 8:14am UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/3 "2017-05-12T08:14:34Z")

</div>

Thank you very mutch Thomas, It worked!

---

<div class="post-metadata">

### Author: ![erion](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@erion](https://discuss.elastic.co/u/erion)
#### Post date: [May 12, 2017, 8:38am UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/4 "2017-05-12T08:38:37Z")

</div>

hi @thomasneirynck,  
the scripted field worked in visualize, but when i try to use it in timelion query like this: .es(index="apache\_elastic", q="@timestamp:[2017-03-22|| TO 2017-03-22||+23h/h]", timefield="hours\_range"), show me null graph. the scripted field call "hours\_range". Can you help me?

---

<div class="post-metadata">

### Author: ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)
#### Post date: [May 26, 2017, 7:57pm UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/5 "2017-05-26T19:57:28Z")

</div>

Hi Erion,

Timelion can't use scripted fields.

---

<div class="post-metadata">

### Author: ![erion](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@erion](https://discuss.elastic.co/u/erion)
#### Post date: [May 29, 2017, 10:24am UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/6 "2017-05-29T10:24:27Z")

</div>

thank you very much... have a good day

---

<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 26, 2017, 10:24am UTC](https://discuss.elastic.co/t/how-to-set-on-x-axis-an-time-range-by-hour/85257/7 "2017-06-26T10:24:38Z")

</div>

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