# Time (y-axis) vs Date (x-axis ) Visualize

**URL:** <https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413>\
**Category:** Kibana\
**Created:** [May 6, 2020, 9:17pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413 "2020-05-06T21:17:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![srajus](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@srajus](https://discuss.elastic.co/u/srajus)\
**Post date:** [May 6, 2020, 9:17pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413/1 "2020-05-06T21:17:41Z")

</div>

Hi All ,

I am planning to create a Dashboard for report monitoring . i need to compare the completion date vs completion time for certain period. i have tried using all the options there is no option gives Time (for Ex : HH or MM ) parameter in Y-axis . all Y-axis options are aggregation -- like count min max or avg ...

is there any way i can create a graph with time parameter on Y-axis and date as X-axis.

my parameters are  
complete-time Apr 30, 2020 @ 05:37:25.908  
timestamp Apr 30, 2020 @ 05:37:26.603 .

any help will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)\
**Post date:** [May 7, 2020, 2:16pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413/2 "2020-05-07T14:16:59Z")

</div>

You could create a "scripted field" in the index pattern under `Kibana Management > Index Patterns`. Choose the index pattern for your data, then click on the "scripted fields" tab. Create a new field.

There are two ways to accomplish this. If you just want the hour then the script looks like

```auto
doc['complete-time'].value.getHour()

```

If you want the minute of the day then the script looks like

```auto
(doc['complete-time'].value.getHour() * 60) + doc['complete-time'].value.getMinute()

```

Once you have the scripted field setup, you can use it in the visualization like any other field. Look at the "top hit" aggregation if you want to just visualize the "last" raw value OR you could use "max".

The only caveat is TSVB doesn't support scripted fields, we are working on a solution for that.

---

<div class="post-metadata">

**Author:** ![srajus](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@srajus](https://discuss.elastic.co/u/srajus)\
**Post date:** [May 7, 2020, 4:01pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413/3 "2020-05-07T16:01:19Z")

</div>

Hi chris,  
i have created scripted field

 ![Screen Shot 2020-05-07 at 10.48.55 AM](https://us1.discourse-cdn.com/elastic/original/3X/f/4/f474efb4615852422a34e3912a953f26e90898d4.png)

when i try to use top hit the Aggregate with list box is empty . the field is defined as date and not a string but still it shows empty.

 ![Screen Shot 2020-05-07 at 10.50.46 AM](https://us1.discourse-cdn.com/elastic/original/3X/3/a/3a4f2a6762de8c286cb1b489eef91d51145d8304.png)

and i tried with max some how y axis is showing jan 1 1970 time stamp for all instead of HH

 ![Screen Shot 2020-05-07 at 11.04.10 AM](https://us1.discourse-cdn.com/elastic/original/3X/d/5/d5bd9c9a6eb3b7a3ee0945f18f99a4ab77d5380d.png)

right now it showing different format instead of **9PM** its showing jan 1,1970 @00.00.00.00.000 **9**  
local time zone is CST and KIbana one is UTC  
Not sure where it went wrong ...

---

<div class="post-metadata">

**Author:** ![simianhacker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simianhacker/32/3383_2.png) [@simianhacker](https://discuss.elastic.co/u/simianhacker)\
**Post date:** [May 7, 2020, 5:12pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413/4 "2020-05-07T17:12:29Z")

</div>

I should have mentioned, set the field type for the scripted field to a `number`. That will allow you to aggregate it like any other metric.

---

<div class="post-metadata">

**Author:** ![srajus](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@srajus](https://discuss.elastic.co/u/srajus)\
**Post date:** [May 7, 2020, 5:23pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413/5 "2020-05-07T17:23:09Z")

</div>

> [@simianhacker](#):
>
> scripted field

thanks Alot it worked Chris. thanks for your support.

---

<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 4, 2020, 5:23pm UTC](https://discuss.elastic.co/t/time-y-axis-vs-date-x-axis-visualize/231413/6 "2020-06-04T17:23:16Z")

</div>

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