Set XValue for Easy Chart

I have a window with an Easy Chart and I use a script in the window’s internalFrameActivated event handler to automatically put the Easy Chart in X-Trace mode. I would like to prevent the user from having to click in the chart to display the vertical dotted line and the X-Trace label(s). Is there a script function I can use to set the X-Trace time for the Easy Chart?

I see that the selectedXValue property of the Easy Chart contains the currently selected X-Trace time. Essentially, what I want to do is write to that property instead of read it but it doesn’t seem to be writeable. I ran the dir() function on the Easy Chart and I see that it includes a method called setSelectedXValue. I tried using that method in a script but it doesn’t seem to do anything. I don’t get an error message but the Easy Chart XValue doesn’t change. I’ve got two Easy Charts in my window one named ‘Easy Chart’ and the other named ‘Easy Chart 1’. Both are in X-Trace mode and are set to the same start date and end date. I have a button with the following code:

component = event.source.parent.getComponent(‘Easy Chart’)
newXValue = event.source.parent.getComponent(‘Easy Chart 1’).selectedXValue
component.setSelectedXValue(newXValue)

Do I need to do something else to ‘Easy Chart’ to make it update?

The NoteChart and EasyNoteChart components in the NoteChart module have updated X-Trace functionality that includes a readable and settable “Trace Timestamp” property that will do what you want, as an actual timestamp (java.util.Date).

Thank you for the suggestion, pturmel. Does that mean the functionality I want to implement can not be done without a 3rd party module? It seems to me that the setSelectedXValue method should work. You mentioned that the NoteChart/EasyNoteChart modules have a “Trace Timestamp” property that is an actual timestamp. The data type for the setSelectedXValue method seems to be a string. That has me wondering if my issue is that the parameter value is not formatted properly but I can’t find documentation for the method. Can you provide it?

The NoteChart/EasyNoteChart doesn’t quite meet my requirements.

Correct. If you dig around in the EasyChart java bytecode you’ll find that setSelectedXValue() delegates to another object inside the easychart which has an empty implementation of setSelectedXValue(). That object has a protected method with a leading underscore that isn’t empty. /-:

Meanwhile, I’d be interested to know what improvements to the NoteChart module would address your requirements… (-:

Not that it fulfills the requirement of editing the X-trace format, but as of 7.9.3 there’s a chart property (“X-Trace Track Mouse”) that does this - as long as you’re in X-trace mode you just need to hover onto the chart component; no clicking required.

From a quick look at the NoteChart documentation it looks like the notes are associated with a timestamp but not with a tag. That’s the main drawback I see. My client wants to see notes associated with a timestamp and a tag path. I’ve been working with the AdHoc Trend template provided by Inductive Automation but have modified it to store annotations by timestamp and tag path instead of timestamp and tag name.

That sounds great, PGriffith. I’ll try it out.

Not really. The notechart module doesn’t do any querying by itself to retrieve annotations. You would bind the notes dataset property to your DB table with annotations with any additional filtering you want in that binding’s where clause. Something like:

SELECT t_stamp, text
FROM annotations
WHERE t_stamp >= '{Root Container.StartTS}'
  AND t_stamp < '{Root Container.EndTS}'
  AND tagpath = '{Root Container.TagPath}'
ORDER BY t_stamp;

Thank you for the clarification. It’s not clear from your documentation that the tagpath is stored with the annotation. Nowhere on the page did I find the word “pen”, “tag”, or “path”. Does the module have a way to graphically indicate which annotation is associated with each tag path, similar to the way the IA template does with a document image on the trend line?

If you want to automatically include all tagpaths on the EasyNoteChart, I would use an intermediate custom property to join the tagpaths into a string, then use that string with an IN clause. The SQL binding would change to:

SELECT t_stamp, text
FROM annotations
WHERE t_stamp >= '{Root Container.StartTS}'
  AND t_stamp < '{Root Container.EndTS}'
  AND tagpath IN ('{Root Container.TagPaths}')
ORDER BY t_stamp;

And then the TagPaths custom property would have something like this as an expression:

objectScript('"\',\'".join([args[0].getValueAt(r, "tag_path") for r in range(args[0].rowCount)])',
  {Root Container.EasyNoteChart.tagPens})

… using objectScript() from the Simulation Aids module, but something similar is possible with runScript().

Well, NoteChart doesn’t do any storage – it simply provides a generic way to display timestamped event annotations. Recording them is up to you. How you record them will dictate your options on how you filter them for display.

Again, that’s up to you. I would suggest placing the tagpath into the tooltip column of the notes dataset. Like so:

SELECT t_stamp, text, tagpath AS tooltip
FROM annotations
WHERE t_stamp >= '{Root Container.StartTS}'
  AND t_stamp < '{Root Container.EndTS}'
  AND tagpath = '{Root Container.TagPath}'
ORDER BY t_stamp

You could also concatenate (In the DB) your annotation with the tagpath and return that as the ‘text’ column. Or, with some extra scripting or SQL joinery, you could arrange for specfic tagpaths to have specific colors. Maybe by matching the pen color.

PGriffith, what are the chances of IA implementing the setSelectedXValue() method of the Easy Chart?

1 Like

I couldn’t tell you, to be totally honest. I’m inclined to think that it’s disabled/restricted for a reason, but I wouldn’t know what that reason is.

If you’d like it added as a feature, then I would recommend posting to http://ideas.inductiveautomation.com/forums/255378-ignition-features-and-ideas - between major/minor releases the devs will go through these suggestions and implement some of the most popular into future versions.

I see that someone already submitted it to the features and ideas portal back in 2015. I went ahead and voted for it.

https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/provide-a-way-to-select-a-pointset-marker-on-an-easychart-through-scripting