# Show X-Trace on a chart by default

**URL:** <https://forum.inductiveautomation.com/t/show-x-trace-on-a-chart-by-default/17230>\
**Category:** Ignition\
**Created:** [March 5, 2018, 5:56pm UTC](https://forum.inductiveautomation.com/t/show-x-trace-on-a-chart-by-default/17230 "2018-03-05T17:56:50Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [April 26, 2023, 2:30pm UTC](https://forum.inductiveautomation.com/t/show-x-trace-on-a-chart-by-default/17230/6 "2023-04-26T14:30:20Z")

</div>

In an Easy Chart, the xTrace option is more or less directly accessible, so in reality, no mouse mimicking hocus pocus is needed, and in the Classic Chart, the xTrace option can still be set; it just requires a little reflection. Using the componentRunning propertyChange event, it is possible to set either chart type to xTrace mode when the Vision Window is opened. It's always worth noting that in the designer, preview mode must be running when the window is opened to get this event to fire.

**Here is a script that would accomplish this in a Classic Chart:**

```auto
if event.propertyName == 'componentRunning':
	chartComponent = event.source
	xTrace = chartComponent.getClass().getSuperclass().getDeclaredField("xtraceItem")
	xTrace.setAccessible(True)
	xTrace.get(chartComponent).setSelected(True)

```

**Here is a script that would accomplish this in an Easy Chart:**

```auto
if event.propertyName == 'componentRunning':
	chartComponent = event.source
	def getXTraceOption(chartComponent):
		if chartComponent.componentCount > 0:
			for component in chartComponent.getComponents():
				if 'PMIEasyChart$EasyChart' in str(component. __class__ ):
					return component.getPopupMenu().getSubElements()[0].getComponent().getItem(3)
				else:
					xTraceOption = getXTraceOption(component)
					if xTraceOption is not None:
						return xTraceOption
		return None
	xTraceOption = getXTraceOption(chartComponent)
	xTraceOption.setSelected(True)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/show-x-trace-on-a-chart-by-default/17230)._
