Module Report - dynamic chart data key

Hi,

I use a table to create pages dynamically. My table data key “usages” is a python list containing multiple variables.
So, for each table row (dynamic page) I would like to put a PyDataset in a timeseries chart.
Each PyDataset is store in a variable like data1, data2, …

To automatically take the right PyDs in each table row, I store its name in each “usages” element.

Is it possible to create a dynamic dta key in a timeseries chart ?


image

image

Thanks

I'm pretty sure you are going to need nested data. You can do this in a script if needed:

Nested query create a QueryResults variable.
image

Is it possible to loop through it in a script ?

I would like to do this like described in manual :
https://docs.inductiveautomation.com/display/DOC81/Charts+Inside+of+Tables
image

equipment_list and downtime_list are basicdatasets ?
My result below :
image

My report script :

inputs = {
			'project_id':data['project_id'],
			}
	
#On génère la date d'aujourd'hui
today=system.date.setTime(system.date.now(),0,0,0)
	
#On génère le num de jour de la semaine	
todayWeekNumber = int(system.date.format(today, "u"))
	
	
# ========================================================
#On va chercher la liste des usages actifs et avec enableReport = 1
#usages = usage.getList(inputs)

usagesList = []
i=1
nested = data['usages'].getCoreResults()
	
	
for row in range(nested.rowCount):

	if nested.getValueAt(row,'state') and nested.getValueAt(row,'enableReport'):
		
		us={
		'database':data['database'],
		'unit':nested.getValueAt(row,'converted_unit'),
		'energy':nested.getValueAt(row,'physical_title'),
		'converted_unit':nested.getValueAt(row,'converted_unit'),
		'physical_title':nested.getValueAt(row,'physical_title'),
		'chart_label':nested.getValueAt(row,'chart_label'),
		'basic_unit':nested.getValueAt(row,'basic_unit'),
		'title':nested.getValueAt(row,'title'),
		'startDate':nested.getValueAt(row,'start_datetime'),
		'config':nested.getValueAt(row,'uconfig'),
		}
		
		end_datetime = nested.getValueAt(row,'end_datetime')
		
		if end_datetime is None:
			us['endDate'] = today
		else:
			us['endDate'] = end_datetime
		
		#Appel de la fonction de génère les résultats
		usData = report.makeUsageData(us)
		
		usDS = usData['outputs']['data']
		data['test'] = type(usDS)# ==> BasicDataset
	
		rowToInsert = us.values()
		headers = us.keys()
		
		rowToInsert.append(usDS)
		headers.append("downtime_list")
		
		rowToInsert.append(usData['outputs']['weeks'])
		headers.append("weeks")
		
		usagesList.append(rowToInsert)
		
data['equipment_list'] = system.dataset.toDataSet(headers,usagesList)

Anyone can help me ?

Thanks a lot :heart: