Easy char X trace Decimal limit

@lrose

Display date in title also getting false. i want to enable it

But I couldn't able to access that property through script

i user dir to get all the property. but i couldn't able to find it

Can you please help me to access that property through script

I thought you were using an Easy Chart?

image
Hovering the mouse cursor over the property reveals what it is, and the code word for X-Axis is Domain, so you have to get the domain axis and apply the scripting name there.

Example:

event.source.parent.getComponent('Chart').chart.plot.domainAxis.displayDayInTitle
2 Likes

Guess I missed that.

1 Like

even for easy chart also it gone Fasle. thanks for the script

from java.text import SimpleDateFormat
	from org.jfree.chart.axis import DateAxis
	dateFormat = SimpleDateFormat("d MMM yyyy")
	timeFormat = SimpleDateFormat("HH:mm:ss")
	dateAxis = DateAxis()
	dateAxis.lowerMargin = 0
	dateAxis.upperMargin = 0
	plot = chart.getPlot()
	plot.setDomainAxis(dateAxis)
	plotDateField = plot.getClass().getDeclaredField('dateFormat')
	plotTimeField = plot.getClass().getDeclaredField('timeFormat')
	plotDateField.setAccessible(True)
	plotTimeField.setAccessible(True)
	plotDateField.set(plot,dateFormat)
	plotTimeField.set(plot,timeFormat)
	self.chart.plot.domainAxis.displayDayInTitle = 1

errro i am getting

14:45:41.133 [AWT-EventQueue-0] ERROR Vision.ClassicChart - Error invoking extension method.
org.python.core.PyException: AttributeError: 'org.jfree.chart.axis.DateAxis' object has no attribute 'displayDayInTitle'
at org.python.core.Py.AttributeError(Py.java:178)
at org.python.core.PyObject.noAttributeError(PyObject.java:965)
at org.python.core.PyObject.object___setattr__(PyObject.java:3821)
at org.python.core.PyObject.object___setattr__(PyObject.java:3792)
at org.python.core.PyObject$object___setattr___exposer.call(Unknown Source)
at org.python.core.PyObjectDerived.setattr(PyObjectDerived.java:1043)
at org.python.pycode.pyx23.configureChart$1(:29)
at org.python.pycode.pyx23.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call
(PyFunction.java:474)
at org.python.core.PyFunction.call(PyFunction.java:469)
at org.python.core.PyFunction.call(PyFunction.java:459)
at org.python.core.PyFunction.call(PyFunction.java:454)
at com.inductiveautomation.vision.api.client.components.model.ExtensionFunction.invoke(ExtensionFunction.java:151)
at com.inductiveautomation.factorypmi.application.components.PMIChart.createChartImpl(PMIChart.java:481)
at com.inductiveautomation.factorypmi.application.components.chart.PMILineChartPanel.createChart(PMILineChartPanel.java:135)
at com.inductiveautomation.factorypmi.application.components.PMIChart.setExtensionFunctions(PMIChart.java:466)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.applyChanges(ComponentScriptEditor.java:596)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor$5.actionPerformed(ComponentScriptEditor.java:337)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
14:45:41.460 [AWT-EventQueue-0] ERROR Vision.ClassicChart - Error invoking extension method.
org.python.core.PyException: AttributeError: 'org.jfree.chart.axis.DateAxis' object has no attribute 'displayDayInTitle'
at org.python.core.Py.AttributeError(Py.java:178)
at org.python.core.PyObject.noAttributeError(PyObject.java:965)
at org.python.core.PyObject.object___setattr__(PyObject.java:3821)
at org.python.core.PyObject.object___setattr__(PyObject.java:3792)
at org.python.core.PyObject$object___setattr___exposer.call(Unknown Source)
at org.python.core.PyObjectDerived.setattr(PyObjectDerived.java:1043)
at org.python.pycode.pyx23.configureChart$1(:29)
at org.python.pycode.pyx23.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call
(PyFunction.java:474)
at org.python.core.PyFunction.call(PyFunction.java:469)
at org.python.core.PyFunction.call(PyFunction.java:459)
at org.python.core.PyFunction.call(PyFunction.java:454)
at com.inductiveautomation.vision.api.client.components.model.ExtensionFunction.invoke(ExtensionFunction.java:151)
at com.inductiveautomation.factorypmi.application.components.PMIChart.createChartImpl(PMIChart.java:481)
at com.inductiveautomation.factorypmi.application.components.chart.PMILineChartPanel.createChart(PMILineChartPanel.java:135)
at com.inductiveautomation.factorypmi.application.components.PMIChart.setExtensionFunctions(PMIChart.java:466)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.applyChanges(ComponentScriptEditor.java:596)
at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor$4.actionPerformed(ComponentScriptEditor.java:327)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

The DateAxis object does not have an attribute 'displayDayInTitle'. This is because the Chart objects don't use the Standard JFreeChart DateAxis, but rather a Sub Class of it.

https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.27/com/inductiveautomation/factorypmi/application/components/chart/AutoTickDisplayDateAxis.html#setDisplayDayInTitle(boolean)

Try this script instead:

	from java.text import SimpleDateFormat
	dateFormat = SimpleDateFormat("yyyy-MM-dd")
	timeFormat = SimpleDateFormat("HH:mm:ss")
	dateAxis = chart.plot.domainAxis
	dateAxisDateField = dateAxis.getClass().getDeclaredField('dateFormat')
	dateAxisTimeField = dateAxis.getClass().getDeclaredField('timeFormat')
	dateAxisDateField.setAccessible(True)
	dateAxisTimeField.setAccessible(True)
	dateAxisDateField.set(dateAxis,dateFormat)
	dateAxisTimeField.set(dateAxis,timeFormat)

Note that in this script I am not overwriting the domainAxis, so any properties that you set in the chart configuration should work as set, and you shouldn't need to set them here.

2 Likes

Checked Its working perfectly thanks