Combine two datasets

Looks like you will have to use 2 datasets afterall in the chart. You can still keep the combined one to show in a table tho

actually what they are doing is splitting single dataset in to 2 separate datasets

yes, but you dont need to split it since you already have the 2 datasets from before.
you just need to add both datasets to the chart instead of the one combined chart

ya correct but user will choose more than 2 .so only planning to give in single dataset

Null values will always leave a “gap”.
You can try to fill up the Null values yourself with some values and lots of math, but that will be quite complex

There also isn’t a way to add datasets to the chart through scripting. (i think) But you can try to add the max number of datasets you will ever likely need ( 10?). You can enable/disable ones that you don’t want to use like this:chart = event.source.parent.getComponent('Chart') chart.setDatasetEnabled("Data", 1) You can set it to a 0 or 1.
And then fill up and activate the ones with those that are selected.

Im afraid there isnt an easy option (that i know off)

Ya OK I will give it a try and check

You will have to post-process one dataset to lie about its time to get them to overlay. Ignition’s charts cannot apply a time shift.

1 Like
tag = event.source.parent.getComponent('Tag Browse Tree').selectedPaths
current_data = event.source.parent.getComponent('Chart').Data
print current_data

offset = 5
endTime = system.date.now()
endTime = system.date.addMinutes(endTime, -15)
startTime = system.date.addMinutes(endTime, -300)
print startTime, endTime

dataSet = system.tag.queryTagHistory(paths=[str(tag.getValueAt(0, 0))], startDate=startTime, endDate=endTime, returnSize=current_data.getRowCount(), aggregationMode="Average", returnFormat='Wide')
print dataSet


columnName = str(tag.getValueAt(0, 0))
colCount = current_data.getColumnCount()
columnData = []

for i in range(dataSet.getRowCount()):
	columnData.append(dataSet.getValueAt(i,1))
	
dataSet = system.dataset.addColumn(current_data, colCount, columnData, columnName, float)
event.source.parent.getComponent('Chart').Data = dataSet

error i am getting

i am trying add column to dataset

by using

system.tag.queryTagHistory(paths=[str(tag.getValueAt(0, 0))], startDate=startTime, endDate=endTime, returnSize=current_data.getRowCount(), aggregationMode=“Average”, returnFormat=‘Wide’)

see the return size i am getting the dataset row count. if query runs it has return the same amount of rows in dataset
but its not returning the same row count

what i did wrong in this?

That error means you have a different number of rows in current_data versus dataSet. You’ll have to adjust the length of columnData to match before you can add the column.

Yes I given the current dataset row count to query to return the same number for rows
Still row count not matching
returnSize=current_data.getRowCount()

What happens if you use returnSize = current_data.getRowCount() + 1, being as you’re one short one the returned dataset?

1 Like

yes, issue is when i select tag from different folder and run the query row count issue happening

when i select within UDT Folder no issue. i found the issue.

this will be also good option returnSize = current_data.getRowCount() + 1 thanks