Dynamic pens in reporting chart

Does anybody have any example code or information on how to get started trying to add dynamic pens to a report chart?

I’ve got a historian query that pulls data based on the unit that a report is running for.

if data[‘unit’] == ‘unit 1’:
historian_tags = [‘tag1’, ‘tag2’, ‘tag3’]
historian_tags = [‘tag4’, ‘tag5’, ‘tag6’]

historian_data = system.tag.queryTagHistory(paths=historian_tags…

The end result would be

pen 1 = list(historian_data.columnNames)[1]
pen 2 = list(historian_data.columnNames)[2]
pen 3 = list(historian_data.columnNames)[3]
… etc

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(),#

# 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':
	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':
	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:


Does this script go in the configureChart function in the Report Chart? I’ve been unable to successfully run this solution.

Any help is appreciated, thanks.

That’s a script data source.