Reporting: combine data sources via scripting for chart dataset

Hi all,

I am having a report that I need to do for a client. I have various SQL queries that return single values to populate text boxes on the report. A pareto bar chart is also required to visually represent these values. Instead of creating another SQL query I am trying to combine the data into data set in the follwing way:

> 	headers = ["name","value"]
> 	rows = [["Baggers Loses",BaggersLoses],["Cartoner Loses",CartonerLoses],
> 	["Packer Loses",PackerLoses],["Conveyor Loses",ConveyorLoses]]
> 	data = system.dataset.toDataSet(headers,rows)
> 	newData = system.dataset.sort(data, "value",0)
> 	#Select Chart object and apply newly created dataset to it
> 	data['Data_Stops'] = newData

Where all the values are predefined in the script and “Data_Stops” is empty DataSet parameter. The error that I get is as follows:

WARN: Error invoking script.Traceback (most recent call last):
  File "<function:updateData>", line 60, in updateData
TypeError: 'com.inductiveautomation.ignition.common.BasicDataset' object does not support item assignment

Anyone can guide me in the right direction where I am getting it wrong?

I got to the solution by myself using the following code:

    toPyDS = system.dataset.toPyDataSet
	xDataSet = toPyDS(system.dataset.toDataSet(['x'], [['Baggers Loses'],['Cartoner Loses'],['Packer Loses'],['Conveyor Loses']]))
	yDataSet = toPyDS(system.dataset.toDataSet(['y'], [[BaggersLoses],[CartonerLoses],[PackerLoses],[ConveyorLoses]]))
	xs = [str(row[0]) for row in xDataSet]
	ys = [float(row[0]) for row in yDataSet]
	rows = zip(xs, ys)
	xyDataSet = system.dataset.toDataSet(['x', 'y'], rows)
	data['Data_Stops'] = xyDataSet
1 Like