Jfreechart tag provider

#1

Hello I have a simple component jfreechart how to insert data from a tag in this graphic
thanks

0 Likes

#2

Is there a reason that you are not using the chart components built in Ignition?

0 Likes

#3

it’s just a test for a component developed from outside of ignition

0 Likes

#4

Someone who does a bit more module development might be able to answer in detail, but you will have to create the properties in the component you import and pass the data in through the designer.

I would take a look at the following link for the github for their vision component example.

This page from the SDK documentation also is useful.
https://docs.inductiveautomation.com/display/SE/Component+Overview

0 Likes

#5

yes I use this example on github when I export the module I try to drag and drop a tag but no data is displayed
thanks

0 Likes

#6

Drag and drop probably is something that would need to be configured separately from the properties.

Hopefully someone who’s done more component stuff will see this. I mostly do modules to import libraries for scripting more than components and stuff.

0 Likes

#7

You would need to add a DnD transfer handler to the component (doesn’t look like the sdk example has one) in order to support it. A good starting point would be to look at this - https://docs.oracle.com/javase/tutorial/uiswing/dnd/intro.html. I’m not entirely sure what the data flavour of tags look like so perhaps someone could chime in on that.

0 Likes

#8

From the Easy Chart, to support drag and drop you’ll want to accept the ListOfNodeBrowseInfo flavor:

boolean fromTree = event.isDataFlavorSupported(ListOfNodeBrowseInfo.FLAVOR);
boolean fromTreeHistorical = event.isDataFlavorSupported(ListOfQualifiedPath.FLAVOR);
boolean fromTable = event.isDataFlavorSupported(VisionAdvancedTable.selectedRowsFlavor);
0 Likes

#9

okay okay is there any other way to read a tag in a chart without drag and drop

0 Likes

#10

Properly expose your fields following the Javabeans property-access style. The designer will automatically turn those javabeans into bindable properties in the designer - then you can just configure a binding on them in the runtime.

0 Likes

#11

I only see the data property in the style field but can not use the tag to display the data

Capture

0 Likes

#12

JFreeChart uses a different backing Dataset class (confusingly), not Ignition’s built-in dataset. Expose a generic ‘data’ property (type ignition.common.Dataset) with a getter and setter. Then when that property changes (ie, once a binding has been applied) you’ll need to pass that Ignition dataset into a new instance of com.inductiveautomation.factorypmi.application.components.chart.runtime.XYNumericDataSet.XYNumericDataSet. The DatasetDescriptor constructor argument bridges the gap between Ignition’s Dataset class and JFreeChart’s.

0 Likes

#13

Ok thanks for the precision do you have a tutorial that explains the unfolding
.

0 Likes

#14

Nope! :slight_smile:

Charts are a particularly rough starting point to build off of. @pturmel may have some advice, I know he’s at least extended the built in charts in one of his modules.

0 Likes

#15

thanks PGriffith @pturmel do you have an example that you suggest

0 Likes

#16

Unfortunately, no. I didn’t have to manipulate the JFreeChart datasets themselves when I wrote the NoteChart module. The key will be to have the setter for your data property initiate the transformation.

0 Likes