# 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:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 25, 2023, 3:14pm UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178/1 "2023-05-25T15:14:00Z")

</div>

Hi,

i am using XY chart. I want to enable x trace without right click and choosing

Is there any option to do it

---

<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, 7:25am UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178/2 "2023-05-26T07:25:52Z")

</div>

If you had asked about a Chart or Easy Chart in Vision, I would have directed you to [this post](https://forum.inductiveautomation.com/t/show-x-trace-on-a-chart-by-default/17230/6).

...but the XY chart is a Perspective thing, and I didn't even know that _right click--\>xtrace_ was an option for that.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 26, 2023, 7:38am UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178/3 "2023-05-26T07:38:23Z")

</div>

XY chart in vision - yes i also tired couldn't find any solution

---

<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, 7:41am UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178/4 "2023-05-26T07:41:42Z")

</div>

Am I missing something? These are the only chart options in my Vision component pallet:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/7/273b9138947104e0a8e470826a438ed270aad6d2.png)

I'm sure I can figure this out; I just need to know which component to work with.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 26, 2023, 7:53am UTC](https://forum.inductiveautomation.com/t/x-trace-enable-in-vision-chart-using-script/74178/5 "2023-05-26T07:53:20Z")

</div>

2 second one **Chart**

---

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

```
