I need some assistance with linking my x and y values to some tags. I tried to use a script in the project library named 'test'. I then used a binding property to run the script I had created that produces the data from a tag. The only issue is that my graph looks empty, it is not populating a line. I'm not sure if its because I may need to use some sort of tag history or what should I do? also, has anyone figured out how to make a XY graph refresh automatically, I don't want to have to refresh the page to be able to see the new data.
def myFunc():
path = ["[default]counter"]
qualifiedValues = system.tag.readBlocking(path)
value = qualifiedValues[0].value
path2 = ["[default]y-axis"]
qualifiedValues2 = system.tag.readBlocking(path2)
value2 = qualifiedValues2[0].value
data = { "example": [{"x":value, "y":value2}]}
return data
I have considered it, however, my X axis would not be time and the Power Chart is time-based. My x axis would be based on a OPC tag that is counting the number of parts being made in production.
This is true, but it will only work with historical tags, and real time is based on how the history is configured, so that’s questionable as to if it’s truly realtime.
It can not be made to work with generated datasets.
You need more than one point in order for the chart to draw a line, so you would need a way to keep track of the previous points location. Perhaps a top level variable in the script library if you don’t want to use history for whatever reason.
Also, in your script you should consolidate your tag reads.
def myFunc():
paths = ["[default]counter", "[default]y-axis"]
qualifiedValues = system.tag.readBlocking(paths)
value, value2 = (qv.value for qv in qualifiedValues)
data = { "example": [{"x":value, "y":value2}]}
return data