Have asked similar questions before, but had pushed this project to the side as it is currently at least functional without this.
I have an area time series chart in perspective that captures a time frame of 12 hours, and within that 12 hours it fills throughout the day with either green or red for each 1 minute segment in which the value of a tag is above a setpoint.
My problem is that, the setpoint is not necessarily static, changing roughly 2-3 times a day, and when this change happens it "back fills" the chart.
Essentially, if from 6:30 am to 8:30 am the set point is 3,000 and the "actual"
is 3,500, it would show green for that time frame. However, if the operator then changes the setpoint to 4,000 at 9 am, it will change the 6:30 to 8:30 block to red.
This is what I am seeking a way to avoid, any help or insight appreciated and let me know if I haven't included enough info.
I have successfully historicized the setpoint since our last interaction here actually, however some part of my process or perhaps my scripting that actually enables the chart seems to be causing issues.
To control the color, it seems to me you will need to perform your comparisons between the process value and the applicable setpoint for that timestamp, not against a constant.
This is the current script for one of the chart's two series, the other series has the comments on the newData.appends reversed.
It is comparing for met or notmet against the setpoint, and having that setpoint as a historized dataset causes the chart to error out.
You have to extract both rate and setpoint within the loop. The history has to have both pens. The output of the transform can still be just the one value, if you don't want to plot the setpoint.
So I would be able to continue using only the two trends to track it? I would just have to include the setpoint into the loop? To my understanding it is already included ahaha. Man I always think I've gotten it figured out just to realize I'm way off perhaps.
Just brainstorming here, but perhaps you can try only using 1 binding for the data. That binding should query the history of the actual tag and the setpoint tag (which also changes over time). Then in the transform create 2 new datasets ["t_stamp","met"] and ["t_stamp","notmet"], loop through your dataset and do the comparison and put the timestamp in both and the resultant value into one or the other datasets (put None in the dataset that you didn't put the resultant value). Then plot both area lines (one green, the other red). These would be overlapping lines, but one will show or the other during their respective times.
How would I even query both? I have been using a property binding tag to access them as they are stored as custom values on the page, so I can only bind to one at a time. Or am I being stupid here?
I was assuming you were utilizing the tag historian on the value tag and also historizing the setpoint tag. Tag Binding would only get you the current real-time value...you need to know what the values where over the previous 12 hours.
Okay I have done a poor job of explaining, I Am actually taking in the value and setpoint datasets through tag history bindings, doing so for each by creating custom values on the view's root. Then, I'm accessing those custom values (Tag histories) through property bindings on the series component of the chart
Good, then you are half-way there. Don't separate your value and setpoint tag history bindings. Create a single tag history query to include both the value and setpoint. Doing so together (and based on your parameters for the history query) should give you a dataset with t_stamp, value, setpoint columns. Then you add a Transform to loop through and do your comparison to create those 2 separate datasets I discussed previously. Your end result of the transform would be a single JSON of 2 "series".
series = [{"name":"met","data":yourmetresultDS},
{"name":"notmet","data":yournotmetresultDS}]
You are wanting the graph to somehow do the dynamic comparison of knowing what is above/below your setpoint but it won't do that. It's job is to graph the data YOU provide only. You have to do the magic yourself.
Okay gotcha, so just pull the setpoint into the same custom value tag history binding as the value, and return it as one dataset, then loop through the same way as I had done so before but the dataset being looped through includes the setpoint, feels obvious in retrospect, feel a bit dumb now even, thank you haha.