# X trace enable in Vision Chart using script

**URL:** <https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 25, 2023, 3:14pm UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178 "2023-05-25T15:14:00Z")\
**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:** [May 26, 2023, 8:07am UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178/6 "2023-05-26T08:07:03Z")

</div>

To have it automatically be in xtrace when the page loads or when the page is opened in the designer while in preview mode, use this script on the chart's propertyChange event handler:

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

```

To do this from a button somewhere on the page, use the button's actionPerformed event handler with this script:

```auto
chartComponent = event.source.parent.getComponent('chart')#path to chart component relative to the button
xTrace = chartComponent.getClass().getSuperclass().getDeclaredField("xtraceItem")
xTrace.setAccessible(True)
xTrace.get(chartComponent).setSelected(True)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178)._
