I am wondering how I can disable any click+drag action on an Easy Chart, as well as disabling the menu that pops up when you right click on it. I don’t want the chart to modified in those ways. Preferably, nothing would happen.
self.setPopupMenu(None)
self.setTransferHandler(None)
Should work; place in configureChart. You may have issues in the designer, because toggling into preview mode doesn’t fire configureChart, but does fire a locale event that recreates the popup menu; but in the actual client that should work fine.
Nothing happens in the client, and this is what shows up in the client console:
10:10:26.889 [AWT-EventQueue-0] ERROR Vision.EasyChart - Error invoking extension method.
org.python.core.PyException: Traceback (most recent call last):
File "", line 11, in configureChart
AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'setPopupMenu'
Huh, that’s pretty weird. What version of Ignition are you using? I copied those directly out of my designer where they were working…
Can you print type(self) before the self.setPopupMenu() call?
v8.0.11 and I just tried v8.0.12
<type 'com.inductiveautomation.factorypmi.application.components.PMIEasyChart'>
I was able to get this to work for the right-click popup
self.getComponent(0).getComponent(0).setPopupMenu(None)
Any other ideas for disabling the zoom? I tried ‘setTransferHandler’ on every component in the EasyChart. I also tried
self.getComponent(0).getComponent(0).setMouseZoomable(False)
self.getComponent(0).getComponent(0).setRangeZoomable(False)
self.getComponent(0).getComponent(0).setDomainZoomable(False)
but nothing seemed to work.
to disable pop up you can use
self.setShowPopup(0) on configureChart, please refer PMIEasyChart (ignition 7.8.4-rc1 API) for more
Has any gotten this to work? I am also hoping to disable the click and drag zoom feature on Easy Charts.
If you want the chart to be view only, you could simply remove the mouse listener:
#def configureChart(self, chart):
chartHolder = self.getComponent(0).getComponent(0)
for listener in chartHolder.mouseListeners:
if listener.__class__.__name__ == 'PMIEasyChart$EasyChart':
chartHolder.removeMouseListener(listener)
Edit:
You could also overlay the chart with something transparent like a label and simply put pass in the transparent component's mouseDragged event handler. This would consume the mouse event and prevent it from reaching the chart.
Thank you so much! Disabling the mouse listener worked! I didn’t try the label overlay trick but that’s a good option that I didn’t think of!
As an update for others, I wasn’t able to get similar script working to disable the zoom on a Classic Chart (I used ‘PMIChart’ instead of ‘PMIEasyChart$EasyChart’ and I also tried removing one of the .getComponent(0) instances in case that was the issue but neither worked) so I tried the label overlay option suggested by Justin above and that worked perfectly as well!