# Time format on Easy Chart X-axis and X-Trace

**URL:** <https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [October 13, 2023, 12:16pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437 "2023-10-13T12:16:47Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![LenRem1](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@LenRem1](https://forum.inductiveautomation.com/u/LenRem1)\
**Post date:** [October 13, 2023, 12:16pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/1 "2023-10-13T12:16:47Z")

</div>

I cannot find a property where I can set the default date/time format for the whole of Ignition or the date/time format used by EasyChart for X-axis times and X-Trace times.  
I am running v8.1.31 on W10 in Europe.

W10 formats date and time like this, which is how I would want it.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/f/df7265cbf1051a60c44bf2701d3d77062aaee9f2.png)  
This is according to my OS settings.

The gateway formats like this on the Status/Performance page  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2a9674ead19cd943dc97ef4602d9190dc799bb51.png)  
Looks good.

The gateway on its Status/Overview page, section Environment says:  
Local time: 2:15:07 PM  
which is obviously not according to my 'locale'

And the EasyChart looks like this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58454646ef6c5359c53a2338988fb7a8568c91d9.png)  
I'd rather have it like `13 Oct 2023` or `13-Oct-2023` and `13:45:29`, like everybody in this corner of the world.

Where should I look to get this right?  
Thanks

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 12:35pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/2 "2023-10-13T12:35:45Z")

</div>

Did some poking around with one of my trending pages and think I found what you're looking for. Under the easy chart's 'Historical Range' header, there should be a property called 'Time Style' that can be changed from Auto, 12HR, or 24HR. Snips for reference below:  
 ![EZchartTime](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/c/ece37fde56e0b8da08092ab1da39d4e74d762c2f.png)  
 ![EZChartTime2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/7/17e19f2d552d1ab262aba0583a884c0ce45edaf4.png)

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 12:39pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/3 "2023-10-13T12:39:07Z")

</div>

Also, welcome to the forum!

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 13, 2023, 12:55pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/4 "2023-10-13T12:55:22Z")

</div>

That fixes the time. How about the date?

> [@LenRem1](#):
>
> I'd rather have it like `13 Oct 2023` or `13-Oct-2023`

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 12:59pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/5 "2023-10-13T12:59:25Z")

</div>

The prop above, 'Date Style,' will allow coarse changes: selections for MDY, DMY, YMD. I assume for finer tuning you'd need to use an extension function like `configureChart`.

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 1:05pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/6 "2023-10-13T13:05:35Z")

</div>

Something like your script below @justinedwards.jle, from [this post](https://forum.inductiveautomation.com/t/how-to-change-color-of-timestamp-and-line-of-x-trace-in-chart/80416) could likely be tweaked to get specific results:

```auto
# Written for the configureChart extension function 
#def configureChart(self, chart):
	from java.text import SimpleDateFormat
	from org.jfree.chart.axis import DateAxis
	pureDateFormat = SimpleDateFormat("")
	pureTimeFormat = SimpleDateFormat("")			
	dateAxis = DateAxis()
	plot = chart.getPlot()
	plot.setDomainAxis(dateAxis)
	plotField1 = plot.getClass().getDeclaredField('dateFormat')
	plotField2 = plot.getClass().getDeclaredField('timeFormat')
	plotField1.setAccessible(True)
	plotField2.setAccessible(True)
	plotField1.set(plot, pureDateFormat)
	plotField2.set(plot, pureTimeFormat)

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 13, 2023, 1:18pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/7 "2023-10-13T13:18:00Z")

</div>

The last time I tried 'YMD' it didn't effect the crosshair label, but it's been a while since I looked at that, so it's possible they have fixed it. If so, that would be the preferable solution.

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 1:21pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/8 "2023-10-13T13:21:08Z")

</div>

@justinedwards.jle pointed me toward a [similar script](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/4) that's closer to what you're looking for @LenRem1. Code as follows:

```auto
def configureChart(self, chart):
	from java.text import SimpleDateFormat
	from org.jfree.chart.axis import DateAxis
	pureDateFormat = SimpleDateFormat("yyyy/MM/dd")
	pureTimeFormat = SimpleDateFormat("h:mm:ss a z")			
	dateAxis = DateAxis()
	plot = chart.getPlot()
	plot.setDomainAxis(dateAxis)
	plotField1 = plot.getClass().getDeclaredField('dateFormat')
	plotField2 = plot.getClass().getDeclaredField('timeFormat')
	plotField1.setAccessible(True)
	plotField2.setAccessible(True)
	plotField1.set(plot, pureDateFormat)
	plotField2.set(plot, pureTimeFormat)

```

With only "" inside the `SimpleDateFormat` argument (from the first script), the date/time tooltip would be removed. Filling that argument with your desired format should get you there.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 13, 2023, 1:24pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/10 "2023-10-13T13:24:13Z")

</div>

The only difference is that a string representation of the date format is passed into `SimpleDatFormat`. Without it, the crosshair label disappears. At least that is the way it behaved in a basic chart. I'm not sure if I've ever applied that script to the Easy Chart, so I can't confirm what the result will be

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 1:24pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/11 "2023-10-13T13:24:54Z")

</div>

Out of curiosity, where does this script run?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 13, 2023, 1:25pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/12 "2023-10-13T13:25:56Z")

</div>

The configureChart extension function in a basic chart is what I wrote it for.

---

<div class="post-metadata">

**Author:** ![Mason\_Stevens](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@Mason\_Stevens](https://forum.inductiveautomation.com/u/Mason_Stevens)\
**Post date:** [October 13, 2023, 1:28pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/13 "2023-10-13T13:28:31Z")

</div>

Ah yeah I see now, bit of a dumb question lol. Haven't dived too deep into extension functions yet. For some reason was thinking it would need to sit in a custom property writing to some properties on the chart.

---

<div class="post-metadata">

**Author:** ![LenRem1](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@LenRem1](https://forum.inductiveautomation.com/u/LenRem1)\
**Post date:** [October 13, 2023, 1:28pm UTC](https://forum.inductiveautomation.com/t/time-format-on-easy-chart-x-axis-and-x-trace/80437/14 "2023-10-13T13:28:48Z")

</div>

Time is ok now.  
Date is more involved. Setting to `DMY` gives me `13/10/2023` on the X-trace and `13 Oct, 2023` below the x-axis. That is kind of acceptable.  
I'll go and see if I can plug in a variation of those scripts sowewhere.  
Thank you all!
