# Chart menu with Scripting

**URL:** <https://forum.inductiveautomation.com/t/chart-menu-with-scripting/17273>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [March 8, 2018, 11:55am UTC](https://forum.inductiveautomation.com/t/chart-menu-with-scripting/17273 "2018-03-08T11:55:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [March 8, 2018, 11:55am UTC](https://forum.inductiveautomation.com/t/chart-menu-with-scripting/17273/1 "2018-03-08T11:55:15Z")

</div>

Hi All,  
I was wondering if someone knows if it’s possible to replicate the Chart’s menu, the right-click menu (MODE,BACKGROUND, etc ) , via script.  
Basically, I’m asking if it’s possible to have a bunch of buttons on the HMI page, where for every single button I have a “property” of the Chart’s Menu.  
So, in this case I’ll have a button for:  
“Zoom” and if clicked I’ll have the possibility to zoom;  
“Pan” and if clicked I’ll have the possibility to pan around;  
and so on…

Thanks for the attention.

Cheers,

---

<div class="post-metadata">

**Author:** ![phillip.bow](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@phillip.bow](https://forum.inductiveautomation.com/u/phillip.bow)\
**Post date:** [March 8, 2018, 4:18pm UTC](https://forum.inductiveautomation.com/t/chart-menu-with-scripting/17273/2 "2018-03-08T16:18:48Z")

</div>

Since the Chart extends from JFreeChart you can use some of the public methods from the ChartPanel class to do it. See the following for a full list of commands:  
[http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/ChartPanel.html](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/ChartPanel.html)

Button -\> actionPerformed:

```auto
from java.awt.event import ActionEvent
from org.jfree.chart import ChartPanel

printCommand = ActionEvent(event.source, ActionEvent.ACTION_PERFORMED, ChartPanel.PRINT_COMMAND)

table = event.source.parent.getComponent("Chart")
table.actionPerformed(printCommand)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 8, 2018, 10:00pm UTC](https://forum.inductiveautomation.com/t/chart-menu-with-scripting/17273/3 "2018-03-08T22:00:44Z")

</div>

Yes, the [chart objects](https://docs.inductiveautomation.com/display/DOC79/Easy+Chart) have a setMode() scripting function (method) that actually performs the mode selection.

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [March 9, 2018, 9:31am UTC](https://forum.inductiveautomation.com/t/chart-menu-with-scripting/17273/4 "2018-03-09T09:31:11Z")

</div>

😍  
Thanks for the info guys! I just made it and already added to my project.  
Thanks again!

Cheers,
