Version:

This lesson is part of the Perspective Components and Bindings course. You can browse the rest of the lessons below.

Supplemental Videos

LESSON

Power Chart - Indirection

Description

In this lesson we'll learn how to apply indirection to the Power Chart, which allows another component on the same view to determine which pens appear on the chart.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] In this lesson, we're going to be taking a look at a specific setup for a power chart, one in which the tag pens the chart is pointing at are tied to some kind of parameter. In short, we refer to this concept as an indirect power chart, meaning a power chart that is using indirection to pull different tag pens into the chart. Now, to get us going I've done a little bit of work already. I've created a machine data type and currently I have four instances in my tag browser here. Each instance has a temperature and a pressure tag. Now, I've taken some other steps, as well. I've created a dropdown component that I've nested in a flex container across the top of my view here and that dropdown just allows the user to select a specific machine, which will end up on the value property of the dropdown. So, if I go into preview mode and select machine two, for instance, then come out of preview mode and select the dropdown, we'll see that the string machine two ends up on that property. Now, one final bit of preparation I've done, I've pulled the temperature and pressure pens for machine one onto our chart, just to give us some sample pens to work with.

[01:10] These pens aren't currently tied to the dropdown in any way. If we'd like to configure indirection on the chart, we can drill down into the chart properties, specifically pens here, and then the first element, and then data, and then that source property is what controls what tag path we're looking at. So, to get our path to be indirect, we can just buy into that source property. So, I'll copy out the current source using Control C, and then click that chain link icon to pull up the binding interface and select an expression binding. And once I'm in there, I'll just paste in that path, put the whole thing in quotes to make it a string, and for those part, this is the right string to use here. We just need one piece of it to be dynamic. So, I'll put a break in the string right where it says machine one, and use that space to pull in a property. And in there, we'll just find our flex container and then our dropdown, and then pull that value property in.

[02:09] Then I'll just link up the different parts of my final string using plus signs, and that's it. I can see from my preview that my expression is working, so I'll go ahead and click okay here. Now, I just want to do the same thing on the other pen. So I'll right click on that source property, say copy binding, and then open up my second pen here, go into the data property, right click on the source property there, and say paste binding. Now, I just need to go in and change the temperature tag reference to a pressure tag reference. And that's it! That's all we need to do to make our chart indirect. So, if I select a different machine in my dropdown, like so, it'll update the tags being shown on the chart. Just as one final note, it's possible to take an entirely different approach here. If we bind on the plots array property instead of the individual tag objects, we could use a script transform to populate the entire pen structure, which would allow us to make our solution a little more robust.

[03:08] For instance, if each machine had a dynamic number of tags that we might want in our chart, we could use that script transform to pull them in. Whichever approach you take, it's not too tricky to set up a power chart that looks at dynamic sets of tags based on a parameter.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.