I’m setting up a PID graphic, and I’d like to show three very basic bar-type indicators for the PID set point, process variable, and controller output. I just want to find a very simple bar graph that fills vertically, from Min to Max, and to put three of them on the page. I’m basically after the bar graph equivalent of a sparkline chart.
The bar chart has a few too many bells and whistles for what I want.
I tried out the moving analog indicator, but it didn’t really suit the purpose - it seems to be aimed more at showing multiple variables all on one indicator (e.g. set point, process variable, limits, interlocks, etc) I can make it kind of work by disabling most of the options and using the “Low Alarm” for the process variable, but it’s a bit of a hack, and then there’s a lot of empty space around the actual graphic where other things would be if they weren’t disabled.
I tried out the progress bar, but that only fills left-right or right-left.
I tried out the level indicator, and that works perfectly, except that it only has a “capacity” parameter, which means that I can’t have the graph start with a negative value, and I need a negative value.
Any ideas for another way to get what I want?
Can be done rather easily using a rectangle and the
system.gui.transform method. Here’s a quick approach I used recently. I added a rectangle and custom properties ‘Min’, ‘Max’ and ‘Value’ (all of integer, float or double type) to a new template. On the templates property changed event I had the following script.
if event.propertyName in ['Max', 'Min', 'Value']:
rec = event.source.getComponent('Rectangle')
min = event.source.Min
max = event.source.Max
val = event.source.Value
height = event.source.height
newH = (val - min) * (height / (max - min))
newY = height - newH
system.gui.transform(rec, newY=newY, newHeight=newH)
This will fill the template from the bottom and up.
I was bored, made a basic bar template that works during design time as well, see attached.
Basic Bar.proj (9.5 KB)
Uploaded a new template due to a minor bug in the first.
Perfect, I can see that working well. I’ll give it a try! Thanks!
edit: hit post and your second reply came up - thanks a heap! I’ll drop that in and test it out.
Works great! I removed the over- and under-scale arrows as my application doesn’t warrant them (but great idea and in other instances I’d use it).
I also encountered a “divide by zero” error when first loading up a display with one of those on it, so I ended up putting an “if” clause in so that if the minimum and maximum are the same, it won’t perform the new height calculation and instead just sets the height to zero.
Thanks for sharing!