How to add trace to a graph


shimh

Recommended Posts

I am trying to dynamically draw different function curves on a graph. So this is what i am doing:

component.graph.addtrace (test1)
component.graph.test1.strYExpression = channelname

It does not work. What did I do wrong?

Link to comment
Share on other sites

What is channelname? Is it a string variable containing the expression? It should not simply be the name of some channel. So, if you have a channel named MyChannel, this would work:

component.graph.addtrace (test1)
component.graph.test1.strYExpression = "MyChannel"

or:

private string channelname = "MyChannel"
component.graph.addtrace (test1)
component.graph.test1.strYExpression = channelname

but this won't:

component.graph.addtrace (test1)
component.graph.test1.strYExpression = MyChannel

since then it would be assigning the contents of MyChannel to the expression.

Link to comment
Share on other sites

  • 2 years later...

Hi

After testing above code I notice that it's not working.

This is the correct way to add trace to a graph:

component.graph.AddTrace ("test1")

component.graph.test1.strYExpression = "MyChannel"

The channel name that is added to the trace must have "_" → AddTrace ("test1")

PS. Have made a example that is attached to this post showing how to add trace with button and quick sequence.

Best Regards

Eythor

EX_AddTrace.ctl

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.