# Easy Chart Xtrace & Mark Mode datetime format

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [December 1, 2022, 5:32pm UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159 "2022-12-01T17:32:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Declan\_McCarthy](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Declan\_McCarthy](https://forum.inductiveautomation.com/u/Declan_McCarthy)\
**Post date:** [December 1, 2022, 5:32pm UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/1 "2022-12-01T17:32:29Z")

</div>

I would like to be able to change the time format in a Vision Easy Chart of the xtrace & mark mode labels to something like, yyyy/MM/dd h:mm:ss a z

I can format the time & place it on the value label of the xtrace label but am unable to change the datetime label , while I can't format anything in Mark mode label

 ![xTrace](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/435a3e4854a529d6e6dbe4e77bbfe73dc0ec96ed.png)  
 ![markMode](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd079ab4eaa08a948750a5f95b0f1b9e0c2d08fd.png)

From other looking at discussions here, I have been able to do it for the tooltip using the code below in a configureChart extension

```
from java.text import SimpleDateFormat
from org.jfree.chart.labels import StandardXYToolTipGenerator

xFormat = SimpleDateFormat("yyyy/MM/dd h:mm:ss a z")

# set the tooltip    
renderer = chart.getPlot().getRenderer()
yFormat = renderer.getBaseToolTipGenerator().getYFormat().getInstance()
#xFormat = renderer.getBaseToolTipGenerator().getXDateFormat().getDateInstance()
renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator("{1} Value {2}", xFormat , yFormat))

```

---

<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:** [December 2, 2022, 12:23pm UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/2 "2022-12-02T12:23:05Z")

</div>

Interesting problem. I'm not yet sure how to go about this, but looking through the [StandardXYItemRenderer Java docs](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/xy/StandardXYItemRenderer.html), the protected [updateCrossHairValues](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.html#updateCrosshairValues-org.jfree.chart.plot.CrosshairState-double-double-int-double-double-org.jfree.chart.plot.PlotOrientation-) method seems promising.

---

<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:** [December 3, 2022, 6:26am UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/3 "2022-12-03T06:26:08Z")

</div>

So far, I have not figured this problem out, but here is what I've learned so far:

There is an exposed property that can change the crosshair label's date format in an Easy Chart, but the desired setting appears to be defective.  
In the **Vision Property Editor** under **Historical Range** , there is a property called **Date Style** :  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/c/dc44abb0fded753423eeb59cd85a5a974d833951.png)

**Changing this to MDY has the following effect:**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d50f44faba2596719a0059a3de4d43f6edb608d.png)

**Similarly, changing this to DMY has this effect:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/7/57434bcfa8bf3056c941ebf4cea8529184d4b6c1.png)

**Inexplicably, changing this to YMD produces the following undesired result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/9/a935b48d0deadfac68c17448e1d4c41157038f6f.png)

Programmatically, this property can be accessed directly from the domainAxis with the setDateStyle method:

```auto
#configureChart extension function
domainAxis = chart.getPlot().getDomainAxis()
domainAxis.setDateStyle(2)
#domainAxis.setDateStyle(0) = MDY
#domainAxis.setDateStyle(1) = DMY
#domainAxis.setDateStyle(2) = YMD

```

...but changing the date style this way yields the exact same result as above

Looking through the declared fields for the domain axis, the mdyFormat, mdFormat, and yFormat fields proved to be SimpleDateFormats that seemed to correlate to the date styles, but assigning a properly formatted SimpleDateFormat to these fields had no effect on the crosshair label.

The domain axis does have a dateFormatOverride method that changes the tick mark labels, but this does not effect the crosshair label.

---

<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:** [December 3, 2022, 9:20am UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/4 "2022-12-03T09:20:28Z")

</div>

**Update:**  
I developed a work around that produces the desired effect by overriding the AutoTickDisplayDateAxis extension of the DateAxis and subsequently customizing the plot's date and time formats.

Here is the code:

```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)

```

**Here is the XTrace Mode result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9e1c9992781dc7b7679a05274a1ca6191f7b33c.png)

**Here is the Mark Mode result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/f/4f81cdc96169527a02f8909e82d2650f1acfdf81.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 3, 2022, 4:30pm UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/5 "2022-12-03T16:30:46Z")

</div>

I made X-Trace mode in my NoteChart module cover all of this customization, partly with extension methods. Sorry, but I did not rework Marker mode.

---

<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:** [December 3, 2022, 9:41pm UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/6 "2022-12-03T21:41:17Z")

</div>

When I get time, I need to test the setDateStyle method on other versions. The date formatting for the YMD setting is clearly an unexpected behavior that needs to be corrected.

---

<div class="post-metadata">

**Author:** ![Declan\_McCarthy](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Declan\_McCarthy](https://forum.inductiveautomation.com/u/Declan_McCarthy)\
**Post date:** [December 5, 2022, 8:04am UTC](https://forum.inductiveautomation.com/t/easy-chart-xtrace-mark-mode-datetime-format/67159/7 "2022-12-05T08:04:11Z")

</div>

Thanks very much Justin, this is a huge help
