Chart and General Notes

I’ve had a request from a customer that has apparently seen this feature on someone else’s software (or at least thinks they have.) They would like the ability to do two things:

  1. On Charts, be able to add a note to a specific point (ex: low tank level) that would stay tagged to that point in the chart. That way, if they go back to look at the chart history, they will be able to see the note at the spot it was added.

  2. One any screen, they want the ability to right-click anywhere on the screen and create a note. They would like the note to either stay on the screen (like a post-it), or possible collapse down to an icon that they can click later on to re-open the note.

It appears that this functionality is going to nearly be a deal breaker for them. I discussed the Comments Panel with them, but the rationale I got back was “we used to make notes on the 20 year old circular chart recorder paper, so we could just pull the chart and see what the operator wrote down. New software should be able to do the same thing!”

Has anyone set up anything similar to this? Thanks in advance.

Number 2 is easy to do with Ignition. We have a wiki example in the IADemo project you can follow. The idea is you put an icon on each window. The icon has a mouse click event that calls a global function that opens another window passing in the window name. The popup is where you would store notes along with that window.

Number 1 is a lot harder to accomplish. It is not built-in to Ignition. The classic chart (not the easy chart) has the ability to select individual data points. You do that by checking the Selection Enabled property of the chart. Once you select a datapoint there is a property called Selected Datapoint you can use in binding or scripting. From that you can add notes by either adding a note column to the history table or adding a whole new table.

If you have more questions or need help trying to get a demo up and running let us know.

Travis,

Thanks, I’ll look into your suggestions. I don’t know why I don’t go look at the IADemo first, I probably would have found the answer you pointed out for #2.

One quick question. In scripting, can I add a new image to a window at a specific x, y coordinate?

Thanks!

No you can’t dynamically add components to a window. However, you can have multiple image components on the window that are invisible. In scripting you can make an image visible, set the image and move it to a x,y position.

OK. That’s the direction I was heading, but I happened to think, if there was a way to dynamically add the image, that would be a little more flexible. Thanks!

OK, I’ve got the second part working, but I’ve got kind of a conceptual question on the chart note. I added a classic chart, tied it to my data, and added a label tied to the Selected Datapoint property for testing. When I pick a point on the chart, it will display, for example:

Data;vinestreettanklevel;2011-04-10 09:26:26;14.5486173629761

Everything is OK to this point. I can set it up to create a note, tag it to this chart and the selected point. My question now is, what would I need to do to have the “Note” icon appear on the chart when this data point is showing on the screen? I’m not exactly sure how to determine the x,y coordinates of the page from what is showing on the chart. Preferably, I would have the icon actually showing on top of this data point. Thanks!

What you’re asking for we call “point annotations”. This is a feature request that we’ve heard before quite a few times.

The short answer is that we can’t accommodate it right now. I’m not sure exactly when we’re adding this feature, it probably won’t be for at least 6 months.

The long answer is that you can sort of do this yourself with scripting directly against the JFreeChart API. This will not be easy if you’re new to scripting.

Put a classic chart on a window, and put a button next to it. Copy and paste this into the button’s actionPerformed event. Hopefully this helps.

[code]chart = event.source.parent.getComponent(“Chart”)

plot = chart.getChart().getXYPlot()

from java.util import Date
from org.jfree.chart.annotations import XYTextAnnotation

today = Date()
plot.addAnnotation(XYTextAnnotation(“Hello World”, today.time, 25.0))[/code]

Carl,

I finally had the time this morning to set up your example to try. When I click the button, I get the following error:

Traceback (innermost last):
File “event:actionPerformed”, line 6, in ?
ImportError: No module named jfree

Any ideas? Thanks!

EDIT:

OK, playing around, I figured out if I added

from org.jfree.chart.annotations import XYTextAnnotation

it works properly. Now, on to figuring out the notes portion of the request! Thanks for the help, Travis and Carl!

Alright, I have another question now. I’m set up to be able to select a point on the chart, add a note to the database, and have it automatically pull up and display the annotation on the chart. I can even change the text color based on the Plot Background color. All is good to this point. The only issue I foresee is, this customer may not like the text showing up on the chart all of the time (because they may enter a paragraph of text, depending on who is making the note.) My first thought was, pop an icon up on the chart to show where notes exist, and let them click the icon to pop up a notes window. I saw in the JFreeChart docs that there is an XYImageAnnotation class that appears to work similarly to the XYTextAnnotation class I have working now. What I’m not sure about are:

  1. Can I access a built-in image to use in XYImage Annotation?
  2. I skimmed the API docs looking for it, but nothing jumped out at me. Can I retrieve the chart x-y coordinates I click on the chart? All I have seen so far is just the Selected Value, which works, and the Selected X Value, which doesn’t appear to return anything.

Thanks again for all the help on this, guys!

You’re pretty quickly getting into territory where you might want to check out the module API…

The easiest way to get a Gateway image would be to put one on the screen in an image component, and then calling [tt].getIcon().getImage()[/tt] on the image component.

You can convert window 2d-space coordinates to chart data-space coordinates through the axes. For example, you can get the domain axis of the XY plot, and call java2DToValue on it. Again, a warning - you’re basically going to have to learn the entire JFreeChart API to do this.

Thanks, Carl. I’m digging into the API as time allows, and also trying to get a little more knowledgeable on Java and Python. You guys are a HUGE help in answering questions on these topics. Thanks again!

OK, I’ve gotten this working pretty well, and didn’t have to resort to a module. :smiley: Two more questions and I’ll hopefully be done with this:

  1. Do you have anything close to a firm timeframe when you will be adding point annotations to Ignition? This will help me determine if I want to keep refining my kludge or not.

  2. As a tangential question, if I have two separate charts on a page, and I want to print them out on the same sheet of paper, is that possible?

Thanks!

I am not sure about the first question but for the second you can use system.print.createPrintJob in scripting to print out the root container which would be both graphs.

Sorry, no, we don't have anything close to a firm timeframe on this.

Hello…

Following the example, when I test the code:

[code]chart = event.source.parent.getComponent(“Chart”)

plot = chart.getChart().getXYPlot()

from java.util import Date
from org.jfree.chart.annotations import XYTextAnnotation

today = Date()
plot.addAnnotation(XYTextAnnotation(“Hello World”, today.time, 25.0))[/code]

I get the following error:

Traceback (innermost last):
File “event:actionPerformed”, line 6, in ?
ImportError: No module named jfree

And I don’t know how to avoid it. Why Ignition does not detect the org.jfree module?

Help please!

Thank you!
Juan Pablo

Add the following two lines to the top of your script:import sys sys.add_package("org.jfree.chart.annotations")