Chart of a constant value

This might be a basic question, but I have had a tough time trying to get the solution.

I have an application for Ignition as a Tag Historian and some of the tags are set points, these set points do not change frequently. I want to plot the process variable and its set point in a chart or easy-chart, but I can see the process variable pen changing, but the set point pen doesn’t show up as a flat line, since the last time it changed is usually out of the time range I am plotting. How can I configure Ignition to show the set point flat line without forcing the storage of it, because my application has several thousands of tags and the hard drive space is precious.

Use a calculated pen to display a constant value:

You can then go into the ‘Calculated Pens’ dataset of the chart and use a Cell Update binding to tie it to the realtime value of your setpoint(s).

1 Like

It is a very good idea, but I don’t know when the user is going to add a tag that is a set point to the chart, so how do we handle this situation?

If you need the end user to have control over the chart, then you can override the onTagsDropped extension function of the chart. You’ll need to have a way to differentiate between setpoint tags and regular tags (presumably, they’ll be named <something>SetPoint).
An example script, from the user manual:

#This will take a tag that gets dropped from a Tag Browse Tree set in Realtime Tag Tree mode,
#and will replace the underscores in the name of the tag "_" and replace them with spaces.
tagPens = self.tagPens
for tag in paths:
    tagPath = tag.replace("default", "~")
    splitTag = tag.split("/")
    name = splitTag[-1].replace("_", " ")
    newRow = [name, tagPath, "MinMax", "Default Axis", 1, 1, system.gui.color(255, 85, 85, 255), "", 1, 1, 0, 1, 0, "", 0, 0, 0, 1, 0, 0]
    self.tagPens = system.dataset.addRow(self.tagPens, newRow)

You’ll need to add a new row to self.calculatedPens rather than self.tagPens, but the core code will be essentially the same.

1 Like

for anyone else trying to use this snippet, beware that the last line should be

self.tagPens = system.dataset.addRow(self.tagPens, newRow)

otherwise if there are multiple tags it only adds the last one to the original dataset. The alternative is to add all the new rows to tagPens and then assign tagPens to self.tagPens to update the easychart object dataset.

1 Like

That’s a great point - I’ve updated my example to suit.
You could also rework it to use the new system.dataset.addRows function added in 7.9.7 to be somewhat more efficient.