# Plotlyjs realtime with system time example

**URL:** <https://community.plotly.com/t/plotlyjs-realtime-with-system-time-example/40345>\
**Category:** plotly.js\
**Created:** [May 31, 2020, 1:15pm UTC](https://community.plotly.com/t/plotlyjs-realtime-with-system-time-example/40345 "2020-05-31T13:15:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoe](https://avatars.discourse-cdn.com/v4/letter/z/a4c791/32.png) [@zoe](https://community.plotly.com/u/zoe)\
**Post date:** [May 31, 2020, 1:15pm UTC](https://community.plotly.com/t/plotlyjs-realtime-with-system-time-example/40345/1 "2020-05-31T13:15:10Z")

</div>

Hi guys, thanks for the hard work.

I am setting up a realtime graph based on the simple example I found on the web.

It used random data for y. A few hassles I am having is how to get the current system time on the xaxis.

I have tried %X, but it gives nothing close to actual system time. Also tried other combos but get really wierd outputs from 01/01/1970 repeated over and over again, to incrementing percentages, etc.

```auto
function getData() {
				
					return Math.random();				
				}
				
				var layout = {
					xaxis: {
						text: 'x Axis',
						//autotick: true,
						//tickformat: '%b %d %Y %H:%M:%S',
						//tickformat: '%H:%M:%S',
						type: "datetime",
						},
						
						//to display time formatted as hh:mm:ss}
					yaxis: {
					
						text: 'y Axis',
						range: [0, 100],
						},
				};
				
			
				
				Plotly.plot('chart',[{
					y:[getData()],
					type:'line'
				}], layout);
				
				var cnt = 0;
				var rangecap = 500;
				
				setInterval(function(){
				
					Plotly.extendTraces('chart',{ y:[[getData()]]}, [0]);
					cnt++;
														
				},15);
				<!-- 3600000 = 1 hour , 60000 - 1 minute-->

```

What I need is the xaxis to show the current system/device time, each hour marked out, each day marked out.

What am I doing incorrectly?

Also how can I add a second realtime data source to getData()? Siuch as…

```auto
function getData() {
    return window.val0, window.val1;
}

```

 ![2020-05-31-001-Workspace 1](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/2/21659c29d26ee2125be19580b8152348755005de.png)

---

<div class="post-metadata">

**Author:** ![Saratoga](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/saratoga/32/28634_2.png) [@Saratoga](https://community.plotly.com/u/Saratoga)\
**Post date:** [July 5, 2020, 12:52am UTC](https://community.plotly.com/t/plotlyjs-realtime-with-system-time-example/40345/2 "2020-07-05T00:52:01Z")

</div>

> [@zoe](#):
>
> ```auto
> var layout = {
> xaxis: {
> text: 'x Axis',
> //autotick: true,
> //tickformat: '%b %d %Y %H:%M:%S',
> //tickformat: '%H:%M:%S',
> type: "datetime" //??????? there is no datetime but it would be date
> },
> 						
> //to display time formatted as hh:mm:ss}
> yaxis: {
> 					
> text: 'y Axis',
> range: [0, 100],
> },
> };
> 
> ```

there is no datetime but it would be date

---

<div class="post-metadata">

**Author:** ![zoe](https://avatars.discourse-cdn.com/v4/letter/z/a4c791/32.png) [@zoe](https://community.plotly.com/u/zoe)\
**Post date:** [July 7, 2020, 8:24am UTC](https://community.plotly.com/t/plotlyjs-realtime-with-system-time-example/40345/3 "2020-07-07T08:24:44Z")

</div>

It has been changed to date but the x-axis still outputs integers starting from zero

```auto
xaxis: {
						text: 'x Axis',
						//autotick: true,
						//tickformat: '%b %d %Y %H:%M:%S',
						//tickformat: '%H:%M:%S',
						type: "date" //??????? there is no datetime but it would be date
						},

```

 ![date](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/6/6c5ff4c624d6a22810c7ce21d96eb1cac6366c2d.png)

---

<div class="post-metadata">

**Author:** ![zoe](https://avatars.discourse-cdn.com/v4/letter/z/a4c791/32.png) [@zoe](https://community.plotly.com/u/zoe)\
**Post date:** [July 13, 2020, 9:00am UTC](https://community.plotly.com/t/plotlyjs-realtime-with-system-time-example/40345/5 "2020-07-13T09:00:51Z")

</div>

Just updated the ja as mentioned. Removed type: “date” and inserted “tickformat: ‘%H:%M’”

I get exactly the same screen as posted, x-axis stars from 0 and increases in integers.

I am pulling in realtime data with a getData() function. Is this perhaps the issue?
