Pens can’t use indirect tags it seems, and I haven’t been able to find any example code for this. I’ve been banging my head against the jfreechart api documentation without any luck.
This is my current solution in case others are looking to do the same.
# Get the historian data.
historian_data = system.tag.queryTagHistory(paths=trend_tags,
startDate=system.date.addMinutes(data['start_event']['calculated_datetime'], -5),#system.date.addMinutes(system.date.now(), -3000),
endDate=system.date.addMinutes(data['stop_datetime'], 5),#system.date.now(),#
returnSize=100,
aggregationMode='Average',
returnFormat='Wide',
noInterpolation=False,
timeout=10000)
# Change the headers on the table to be static.
pyds = system.dataset.toPyDataSet(historian_data)
headers = ['t_stamp']
index = 0
for name in pyds.columnNames:
if name == 't_stamp':
continue
col_name = 'tag' + str(pressure_index)
index += 1
rows = [[value for value in row] for row in pyds]
data['trend_data'] = system.dataset.toDataSet(headers, rows)
# Add the actual tag names, and static colors assigned to the pens to a table.
legends = {0:[], 1:[], 2:[], 3:[]}
for index, tag_name in enumerate(pyds.columnNames):
if tag_name == 't_stamp':
continue
legends[(index-1) % 4].append([colors[headers[index]], tag_name.strip('TAG_FOLDER/')])
for legend, tags in legends.items():
data['legend'+str(legend)] = system.dataset.toDataSet(['color', 'tag'], tags)
This allows you to have a table, and 4x tables below that ends up looking something like this: