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