I have a classic XY chart in my Vision application that currently shows the elapsed time in the x-axis (in minutes). It achieves this by having 2 datasets (called data and rawHistory, with rawHistory bound to the Tag History for several tags):

and using a propertyChange script to take the rawHistory timestamp, subtract it from the current time to get an elapsed time in milliseconds and putting that information into the data dataset:
if event.propertyName == "rawHistory":
rawData = event.newValue
headers = list(rawData.getColumnNames())
newData = []
pyData = system.dataset.toPyDataSet(rawData)
now = system.date.now().time
for row in pyData:
t_stamp = row[0].time
# (Timestamp - Now) = Negative Milliseconds
msAgo = t_stamp - now
# Create the new row using the millisecond value
newRow = [msAgo]
for i in range(1, len(row)):
newRow.append(row[i])
newData.append(newRow)
finalDS = system.dataset.toDataSet(headers, newData)
event.source.data = finalDS
The chart is then configured to enable only the data dataset (rawHistory dataset is not charted) and to have an Elapsed Time axis for the X-axis:
and the Elapsed Time X-axis format is configured in the Chart Customizer to show in minutes:
This will show the XY chart with elapsed time from 0 to 20 minutes along the x-axis. The problem I have is that when I use the X-trace, it shows the value of the x-axis in milliseconds (-584755.0 in the screenshot below) instead of minutes (ignore the black rectangles - just hiding tag names):
I have found script in this forum to format the y-axis using the getXTraceLabel() extension function but I am new to Python struggling to figure out how to change the format of the x-axis from milliseconds to seconds, or maybe even from milliseconds to time of day. In addition, any script I am finding seem to only format the X-trace labels containing the values (white, green, red and blue labels above) and not the time X-trace label. Can anyone please help?


