# What is wrong with my implemented Interface?

**URL:** <https://forum.inductiveautomation.com/t/what-is-wrong-with-my-implemented-interface/58515>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [April 16, 2022, 12:40am UTC](https://forum.inductiveautomation.com/t/what-is-wrong-with-my-implemented-interface/58515 "2022-04-16T00:40:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [April 16, 2022, 12:40am UTC](https://forum.inductiveautomation.com/t/what-is-wrong-with-my-implemented-interface/58515/1 "2022-04-16T00:40:28Z")

</div>

Working on Vision, Chart component in _configureChart_ Extension Function.

I’m trying to rewrite and/or hide some pens name that is appearing in the legend. I’m trying to use the method [setSources()](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/title/LegendTitle.html#setSources-org.jfree.chart.LegendItemSource:A-) that needs [LegendItemSource](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/LegendItemSource.html) interface.

I’m implementing this with

```auto
class MyLegendItemSource(LegendItemSource):
	def getLegendItems(self):
		return legendItemsOverride

```

when I call the method’s class I’m getting:

```auto
print MyLegendItemSource().getLegendItems()
output: org.jfree.chart.LegendItemCollection@56a7d44b

```

However, when I attempt to set the source with `legend.setSources(MyLegendItemSource())`. Where `legend = chart.getLegend()`

I’m getting this:

```auto
[AWT-EventQueue-0] ERROR Vision.ClassicChart - Error invoking extension method.
org.python.core.PyException: Traceback (most recent call last):
  File "<extension-method configureChart>", line 68, in configureChart
TypeError: setSources(): 1st arg can't be coerced to org.jfree.chart.LegendItemSource[]

	at org.python.core.Py.TypeError(Py.java:235)
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)
	at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)
	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:167)
	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:204)
	at org.python.core.PyObject. __call__ (PyObject.java:404)
	at org.python.core.PyObject. __call__ (PyObject.java:408)
	at org.python.core.PyMethod. __call__ (PyMethod.java:124)
	at org.python.pycode._pyx1702.configureChart$1(<extension-method configureChart>:68)
	at org.python.pycode._pyx1702.call_function(<extension-method configureChart>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
	at org.python.core.PyFunction.function ___call__ (PyFunction.java:376)
	at org.python.core.PyFunction. __call__ (PyFunction.java:371)
	at org.python.core.PyFunction. __call__ (PyFunction.java:361)
	at org.python.core.PyFunction. __call__ (PyFunction.java:356)
	at com.inductiveautomation.vision.api.client.components.model.ExtensionFunction.invoke(ExtensionFunction.java:152)
	at com.inductiveautomation.factorypmi.application.components.PMIChart.createChartImpl(PMIChart.java:489)
	at com.inductiveautomation.factorypmi.application.components.chart.PMILineChartPanel.createChart(PMILineChartPanel.java:136)
	at com.inductiveautomation.factorypmi.application.components.PMIChart.setExtensionFunctions(PMIChart.java:474)
	at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.applyChanges(ComponentScriptEditor.java:599)
	at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.access$600(ComponentScriptEditor.java:85)
	at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor$4.actionPerformed(ComponentScriptEditor.java:330)
	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.access$500(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.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$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.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)

```

What I missing since is not the first time I’m implemeting an interface.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 16, 2022, 1:03am UTC](https://forum.inductiveautomation.com/t/what-is-wrong-with-my-implemented-interface/58515/2 "2022-04-16T01:03:34Z")

</div>

> [@jespinmartin1](#):
>
> `1st arg can't be coerced to org.jfree.chart.LegendItemSource[]`

Looks like it's expecting an array of `LegendItemSource`.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [April 16, 2022, 4:10am UTC](https://forum.inductiveautomation.com/t/what-is-wrong-with-my-implemented-interface/58515/3 "2022-04-16T04:10:13Z")

</div>

Yep, my bad. I didn’t notice `[]`. Thanks @Kevin.Herron
