Bar Chart Target Line

Is there a way to add a target line(s) to a bar chart in a vision window?

Thanks in advance.

A solution would be to add this in the propertyChange event of your barChart:

if event.propertyName == "data":
   from org.jfree.ui import Layer
   from org.jfree.ui import RectangleAnchor
   from org.jfree.ui import TextAnchor
   from org.jfree.chart.plot import ValueMarker
   from java.awt import BasicStroke, Color
   
   stroke = BasicStroke(2.0)
   color = Color(255,0,0)
   plot = event.source.getChart().getPlot()
   
   targetValue = ValueMarker(27.0);   
   targetValue.setLabelAnchor(RectangleAnchor.LEFT)
   targetValue.setLabelTextAnchor(TextAnchor.CENTER_LEFT)
   targetValue.setLabel("Target")
   targetValue.setStroke(stroke)
   targetValue.setPaint(color)
   plot.addRangeMarker(targetValue, Layer.BACKGROUND)

This code adds a 2pt red line labeled “Target” at the range value of 27.0.

There are a lot of information for customisation in the jfreeChart API doc.

3 Likes

Is there a way to add a tag reference or a value from a query into the ValueMarker()? I have tried @Query.NestedQuery.Average@ and data[‘NestedQuery’].getNestedQueryResults(). This is specific to a report chart.