Reporting - dynamic chart keys

Hi All

My task is to create one report that will be used for several devices.

I have created a report and I am passing in a parameter called ‘tagName’ to switch between the device tag structures.

I am populating a timeseries chart with 2 historical tags. Using a script data source, I can switch between the historical tags and write it to the “bandwidth” key.


In the screenshot above, the range key has been populated using the default value of the deviceName tag. The issue is that this Range Key will only work with one of my devices. I want to make it “devices[‘deviceName’]ratedown_”. How do I make the Range Key dynamic? I have looked at scripting and the JFreeChart but I don’t know where to start. Any help would be most welcome.


Hi All.

I was overcomplicating things. My solution was to use “columnNames” in the query string to rename the “columns” to a generic name (‘upload’ and ‘download’ in my case). This made them device agnostic and my report works as desired.

# Load the parameter containing the device name
deviceName = data['deviceName']
# Build the tag paths
tagPath1 = '[MSSQLExpress]devices/' + deviceName.lower() + '/rateup'
tagPath2 = '[MSSQLExpress]devices/' + deviceName.lower() + '/ratedown'
tagPaths = [tagPath1, tagPath2]
# Define the new column names
columns = ['upload', 'download']
# Build the query and get the data
data['bandWidth']=system.tag.queryTagHistory(paths=tagPaths, startDate=data['StartDate24hr'], endDate=data['EndDate'], returnSize=1000, aggregationMode='Average', returnFormat='Wide', columnNames=columns)