Wind Direction Easy Chart

So I am trying to get my easy chart to implement different wind directions based on the historical wind direction value. This would be on a historical wind speed avg calculated pen. I looked into the Jfreechart documentation a bit but couldn’t figure out a way to do this. The ultimate goal would be to have something similar to what the picture shows. I know I can do a workaround by using getXTraceLabel and writing the value to a custom property and having a component tied to that value but I would like to do it dynamically on the graph if feasible.

Well, as a starting point, you’re going to need to generate a custom subclass or instance of XYLineAndShapeRenderer and assign it your your series/plot.
Rendering a different instance of the shape for each point seems to not be an intended feature of JFreeChart, but does seem possible by overriding the appropriate methods.

Getting directional information into the chart might be somewhat complex; I assume that’s a second piece of information correlated to time, but JFreeChart will try to have that render as another axis.

Yea the other historical data is just the degree that the wind is blowing with 0 being north and 180 being south. It might work easier if I use less granular data, like 1-12 for the directional. I’ll look into it and see what I can figure out.

You can use a shape object and rotate.

ShapeUtilities.rotateShape(myShape, angleRad, 0,0)


Hey so I did some research into it, plus got sidetracked with some other projects, and was able to get an instance of the pen dataset using pen = chart.getPlot().getDataset(0) which gave me com.inductiveautomation.factorypmi.application.components.chart.easychart.PenDataset@3952c969 .
I also used pen = chart.getPlot().getDataset(0).getPens() and got [PenData(pen=Tag[Wind Direction],dataset=null)].
Are either of these the correct information to do what I am trying to do and if so, how do I access the individual data points throughout as well as use those data points to change the direction of the shape.
On the XYLineAndShapeRenderer the drawItem() seems to be the most promising but I’m not sure how to get all of the required arguments to override it.
On top of that I would need to draw an instance of my own custom shape on there as the current shapes aren’t pointed in a specific direction.

1 Like