# Chart and General Notes

**URL:** <https://forum.inductiveautomation.com/t/chart-and-general-notes/2867>\
**Category:** Ignition\
**Created:** [April 14, 2011, 2:42pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867 "2011-04-14T14:42:53Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [April 14, 2011, 2:42pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/1 "2011-04-14T14:42:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 14, 2011, 4:13pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/2 "2011-04-14T16:13:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [April 14, 2011, 8:50pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/3 "2011-04-14T20:50:41Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 14, 2011, 11:32pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/4 "2011-04-14T23:32:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [April 15, 2011, 12:36pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/5 "2011-04-15T12:36:34Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [April 15, 2011, 5:25pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/6 "2011-04-15T17:25:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [April 16, 2011, 12:57am UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/7 "2011-04-16T00:57:02Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [April 20, 2011, 2:34pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/8 "2011-04-20T14:34:32Z")

</div>

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

```auto
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!

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [April 22, 2011, 4:39pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/9 "2011-04-22T16:39:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [April 29, 2011, 4:23pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/10 "2011-04-29T16:23:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [May 2, 2011, 12:45pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/11 "2011-05-02T12:45:46Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jgreenewv](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jgreenewv](https://forum.inductiveautomation.com/u/jgreenewv)\
**Post date:** [May 25, 2011, 8:43pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/12 "2011-05-25T20:43:11Z")

</div>

OK, I’ve gotten this working pretty well, and didn’t have to resort to a module. 😃 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!

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 26, 2011, 11:59am UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/13 "2011-05-26T11:59:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 30, 2011, 4:43am UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/14 "2011-05-30T04:43:03Z")

</div>

> [@jgreenewv](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![Juan\_Pablo\_Manson](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@Juan\_Pablo\_Manson](https://forum.inductiveautomation.com/u/Juan_Pablo_Manson)\
**Post date:** [June 13, 2011, 7:22pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/15 "2011-06-13T19:22:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [June 27, 2011, 2:59pm UTC](https://forum.inductiveautomation.com/t/chart-and-general-notes/2867/16 "2011-06-27T14:59:33Z")

</div>

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