# Set X-Trace on Easy Chart to specific date/time

**URL:** <https://forum.inductiveautomation.com/t/set-x-trace-on-easy-chart-to-specific-date-time/81944>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [November 15, 2023, 6:39pm UTC](https://forum.inductiveautomation.com/t/set-x-trace-on-easy-chart-to-specific-date-time/81944 "2023-11-15T18:39:55Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [November 15, 2023, 7:46pm UTC](https://forum.inductiveautomation.com/t/set-x-trace-on-easy-chart-to-specific-date-time/81944/4 "2023-11-15T19:46:23Z")

</div>

> [@bschroeder](#):
>
> no easy way to do it natively?

I honestly would have expected changing the plot's domainCrosshairValue to move the xTrace, but I couldn't get it to work event with a repaint. What I did get to work was calculating the x-coordinate from the domain location and simulating a mouse click using robot. Here is the custom method I developed that simply requires the specified date in millis to be passed in:

```auto
def setXTrace(self, timeStampInMillis):
	from java.awt import Robot
	from java.awt.event import MouseEvent
	
	# Get the internal EasyChart Class, the JFreeChart, and the plot
	chartField = self.getClass().getDeclaredField('chart')
	chartField.setAccessible(True)
	easyChartPanel = chartField.get(self)
	chart = easyChartPanel.chart
	plot = chart.plot
	
	# Calculate the x-coordinate based on the time in millis
	xCoordinate = int((timeStampInMillis - plot.domainAxis.lowerBound) / (plot.domainAxis.upperBound - plot.domainAxis.lowerBound) * easyChartPanel.width)
	
	# Create a robot for simulating mouse events
	robot = Robot()
	
	# Simulate a mouse click event at the calculated x-coordinate within the easyChart
	robot.mouseMove(easyChartPanel.locationOnScreen.x + xCoordinate, easyChartPanel.locationOnScreen.y)
	robot.mousePress(MouseEvent.BUTTON1_MASK)
	robot.mouseRelease(MouseEvent.BUTTON1_MASK)

```

Alternatively, you could simply draw a value marker on the chart to mark the location of the alarm event. Here is an example I developed for the easy chart that you could possibly adapt to your requirement:

> [@Two X-Trace on Easy Chart](https://forum.inductiveautomation.com/t/two-x-trace-on-easy-chart/80938/3):
>
> Well, this is Vision, so just about anything that is not included with the module is theoretically possible if you are willing to build it yourself. The only question is how deep down the rabbit hole a developer is willing to go to get the result they want. In this case, the crosshair could be created with a value marker, and the labels could be created with xy text annotations. If you only ever need two x traces at the same time, then I would create a custom property on the parent container of…

---

_[View the full topic](https://forum.inductiveautomation.com/t/set-x-trace-on-easy-chart-to-specific-date-time/81944)._
