Show X-Trace on a chart by default

Is it possible to show the X-Trace on a chart when the page is loaded (without having to click on the graph)? I set the mode to 4 (self.setMode(4)) but I don’t know how to make the X-Trace to be visible by default.

I don’t know of a way to do it with Ignition’s built-in charts. It can be done with the NoteChart Module with both the classic NoteChart and the EasyNoteChart by assigning a date/time to the traceTS property with a script. Or possibly bind that to now() to maintain an XTrace of the latest values.
See the feature list in the documentation.

1 Like

Is there a way to change the X-Trace label color on the classic Note Chart? By default, the label has the same color as the graph, but if light colors are used, it is difficult to see it on the white background. Ideally, I would like to see the labels black (same as the time stamp).
Can the visibility on the X-Trace be change? One option is to change the trace timestamp so it will be outside of the domain axis, but this won’t work for me.

Unfortunately, no. And no convenient way to change that. Presumably, if the chosen color is hard to read, it’d be hard to see the line, too. Note that the text of the X-Trace value is painted on a partially transparent background, repeating the chart background. That makes the labels more readable when on top of a tangle of lines, but there still has to be some contrast.[quote=“cstoica, post:3, topic:17230”]
One option is to change the trace timestamp so it will be outside of the domain axis, but this won’t work for me
It has to stay within the chart as all of the outer boundary decorations can be turned off. The chart area itself is the only sure place to put it (along with the value labels).

It's a bit hacky, but after self.setMode(4) you can simulate a mouse click on the chart control and the the x-trace will show up:

from java.awt.event import MouseEvent 
chart = event.source.parent.getComponent('Chart')
evt = MouseEvent(chart, # which
		MouseEvent.MOUSE_CLICKED, # what ), # when
		0, #// no modifiers
		5000, 10, # where: at (5000, 10} - go to the latest record in the chart
		1, # only 1 click 
		False); # not a popup trigger

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:

if event.propertyName == 'componentRunning':
	chartComponent = event.source
	xTrace = chartComponent.getClass().getSuperclass().getDeclaredField("xtraceItem")

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

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)
					xTraceOption = getXTraceOption(component)
					if xTraceOption is not None:
						return xTraceOption
		return None
	xTraceOption = getXTraceOption(chartComponent)

Old post but very useful. Thank you!

1 Like