# Bar chart (report) static line

**URL:** <https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445>\
**Category:** Ignition\
**Created:** [June 13, 2018, 2:02pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445 "2018-06-13T14:02:15Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 16, 2020, 8:58pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/21 "2020-06-16T20:58:20Z")

</div>

So, yes, [`JFreeChart.getPlot()`](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html) returns an instance of the [`Plot`](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/Plot.html) interface - at the top of the Javadoc for the interface, you can see the known subclasses:

> Direct Known Subclasses:  
> [CategoryPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/CategoryPlot.html), [CompassPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/CompassPlot.html), [DialPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/dial/DialPlot.html), [FastScatterPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/FastScatterPlot.html), [MeterPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/MeterPlot.html), [MultiplePiePlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/MultiplePiePlot.html), [PiePlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/PiePlot.html), [PolarPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/PolarPlot.html), [SpiderWebPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/SpiderWebPlot.html), [ThermometerPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/ThermometerPlot.html), [WaferMapPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/WaferMapPlot.html), [XYPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/XYPlot.html)

If you drill into the [`XYPlot`](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/XYPlot.html) - the most common type of plot you'll see in Ignition, aside from `CategoryPlot`s, which back pie charts and bar charts. `XYPlot`, meanwhile, lists its direct known subclasses:

> Direct Known Subclasses:  
> [CombinedDomainXYPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/CombinedDomainXYPlot.html), [CombinedRangeXYPlot](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/CombinedRangeXYPlot.html)

And then you can see that the `CombinedDomainXYPlot` has the `getSubplots()` method.

Or, you can 'back into' things from the other direction:  
`print type(event.source.chart.plot)`, which should give you the full classname: `org.jfree.chart.plot.CombinedDomainXYPlot`, which you can then just look up directly via Google/etc.

The reverse-engineering approach is made a lot more palatable/powerful via the use of @pturmel's inspect.py module, which you can find posted on the forums here.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [June 16, 2020, 9:09pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/22 "2020-06-16T21:09:05Z")

</div>

Thanks for the in-depth response! I think that will help a lot for future tracing. Especially the reminder to use print type(). I think i’ve had a play with the inspect.py module, maybe i’ll have to get more familiar.  
It mainly seems to be dealing with Charts that requires more digging into Java than anything else.

---

<div class="post-metadata">

**Author:** ![Lionel\_Maree](https://avatars.discourse-cdn.com/v4/letter/l/858c86/32.png) [@Lionel\_Maree](https://forum.inductiveautomation.com/u/Lionel_Maree)\
**Post date:** [August 22, 2022, 8:28am UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/23 "2022-08-22T08:28:23Z")

</div>

Hi,

I hope you can help.

I have used a similar script and it works. the other problem that I have is this only add the marker on the default axis (left axis). i need to put a “marker” on the second axis as well. is there a way of setting it on the second axis (right axis)?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 23, 2022, 3:45am UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/24 "2022-08-23T03:45:01Z")

</div>

@Lionel_Maree  
If you are asking for vertical markings, this can be accomplished by using “addDomainMarker” instead of “addRangeMarker”

**Example:**

```auto
from org.jfree.chart.plot import CategoryMarker;
from org.jfree.ui import Layer
marker = CategoryMarker("Mar")
marker.setPaint(system.gui.color(10, 10, 10, 40))
event.source.parent.getComponent('Bar Chart').chart.plot.addDomainMarker(marker, Layer.BACKGROUND)

```

**The preceding code produces the following result:**  
 ![Sample Code 2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c0c8dd0d71b29d4fc4ed6630c29264d499aa459a.png)

---

<div class="post-metadata">

**Author:** ![Lionel\_Maree](https://avatars.discourse-cdn.com/v4/letter/l/858c86/32.png) [@Lionel\_Maree](https://forum.inductiveautomation.com/u/Lionel_Maree)\
**Post date:** [August 23, 2022, 6:39am UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/25 "2022-08-23T06:39:38Z")

</div>

I must probably clarify that I’m using a time series chart instead of a bar chart but should not make a difference or that much of a difference. 🙂

I don’t want vertical lines. the Filtrate turb (Upper) is correct which is referencing to the left y-axis. only thing that I want extra is the Turb Removal Baseline must use the the right y-axis as reference because the range or scaling will be different on each y-axis.  
 ![Capture345353](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e9276154e77d5ac87bd49da967af930f94596bc.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 23, 2022, 8:16am UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/26 "2022-08-23T08:16:11Z")

</div>

I was able to accomplish this using an intermediary ratio in the script to translate the coordinates from the left to the right. Here is the sample code:

```auto
from org.jfree.chart.plot import IntervalMarker
rightAxisLowSetPoint = 40
rightAxisHighSetPoint = 60
leftAxisMin = 0
leftAxisMax = 100
rightAxisMin = 20
rightAxisMax = 80
translatedLowSetPoint = (rightAxisLowSetPoint*leftAxisMax)/rightAxisMax
translatedHighSetPoint = (rightAxisHighSetPoint*leftAxisMax)/rightAxisMax
event.source.parent.getComponent('Chart').chart.plot.addRangeMarker(IntervalMarker(rightAxisLowSetPoint, rightAxisHighSetPoint, system.gui.color(20, 10, 10, 40)))

```

**This is the sample result:**

 ![Sample Result](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/e/fead2b32d1c8e1a5540a37b966c383fa8c1164ee.png)

---

<div class="post-metadata">

**Author:** ![ajrowe](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ajrowe](https://forum.inductiveautomation.com/u/ajrowe)\
**Post date:** [April 26, 2023, 8:24pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/27 "2023-04-26T20:24:29Z")

</div>

I want to do a similar shading, except across a date x-axis of an XY Plot, based on the start/end dates of a date slider. I've tried by CategoryMarker and Marker with no luck:

from org.jfree.chart.plot import Marker;  
from org.jfree.ui import Layer

sDate = self.parent.getComponent('Date Range').startDate  
eDate = self.parent.getComponent('Date Range').endDate  
marker = Marker(startDate, endDate)  
marker.setPaint(system.gui.color(10, 10, 10, 40))

chart = event.source.parent.getComponent("Chart").getChart()  
chart.getPlot().addDomainMarker(marker, Layer.BACKGROUND)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [April 27, 2023, 4:09am UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/28 "2023-04-27T04:09:02Z")

</div>

I see a few things that need to be corrected in your code in order to accomplish this.  
• `sDate` and `eDate` are assigned date values, but are never used. Instead when the marker is constructed, two unassigned variables `startDate` and `endDate` are used.  
• For this, I believe that the marker you want is actually `IntervalMarker`, and I don't believe that the ui layer is needed  
• I don't usually see `event.source` and `self` in the same script unless this is being fired from a custom method and an event is passed in.  
• Also, for an xyPlot, the dates need to be converted to millis

Other than those minor things, the code should run.

**Here is the corrected code:**

```auto
from org.jfree.chart.plot import IntervalMarker
chart = event.source.parent.getComponent("Chart").getChart()#changed self to event.source (if this change was backwards, then reverse it for all instances)
dateRange = event.source.parent.getComponent('Date Range')
startDate = dateRange.startDate.getTime()#changed startDate and endDate to match what's being used to construct the marker
endDate = dateRange.endDate.getTime()#added getTime to convert date to millis
marker = IntervalMarker(startDate, endDate)#switched plot marker to interval marker
marker.setPaint(system.gui.color(10, 10, 10, 40))
chart.plot.addDomainMarker(marker)#Removed layer specification

```

---

<div class="post-metadata">

**Author:** ![ajrowe](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ajrowe](https://forum.inductiveautomation.com/u/ajrowe)\
**Post date:** [May 4, 2023, 5:53pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/29 "2023-05-04T17:53:42Z")

</div>

Yep, you fixed it for me. Thanks so much!

---

<div class="post-metadata">

**Author:** ![jfan](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jfan](https://forum.inductiveautomation.com/u/jfan)\
**Post date:** [June 12, 2023, 4:27pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/30 "2023-06-12T16:27:54Z")

</div>

Is it possible to add multiple target lines in the bar chart?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 12, 2023, 4:38pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/31 "2023-06-12T16:38:07Z")

</div>

I don't know, but probably. Have you tried?

---

<div class="post-metadata">

**Author:** ![jfan](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jfan](https://forum.inductiveautomation.com/u/jfan)\
**Post date:** [June 12, 2023, 4:42pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/32 "2023-06-12T16:42:33Z")

</div>

@PGriffith I have tried to add two markers with the code you provided above, but it was not working. I am also not familiar with this.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 12, 2023, 4:44pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/33 "2023-06-12T16:44:31Z")

</div>

"Not working" is pretty vague.  
Was an error being thrown? Maybe quietly, in the output console?  
Was only one of the added markers showing up? If so, which one - the first one you added, or the second?  
As the rest of this thread gets into - do you have multiple subplots? Is this a chart in Vision, or Reporting?  
What's the exact code you were using to try to add two markers?

Help me help you. The more information you provide, the better.

---

<div class="post-metadata">

**Author:** ![jfan](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jfan](https://forum.inductiveautomation.com/u/jfan)\
**Post date:** [June 12, 2023, 4:49pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/34 "2023-06-12T16:49:22Z")

</div>

@PGriffith ,Sorry for the lack of information.

I don't see any error in the console. Dont have subplots.

here is the code that I implemented:

```auto
	from org.jfree.chart.plot import ValueMarker
	marker = ValueMarker(0) #point on range axis to label
	label = 'Avg: '+str(data['average'])[0:5]
	marker.setLabel(label)
	chart.getPlot().addRangeMarker(marker)
	
	marker1 = ValueMarker(-0.1) #point on range axis to label
	label = 'Avg: '+str(data['average'])[0:5]
	marker1.setLabel(label)
	chart.getPlot().addRangeMarker(marker1)

```

I am using the bar chart in the report module. Only the first one showed up in the chart.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 12, 2023, 4:52pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/35 "2023-06-12T16:52:00Z")

</div>

> [@jfan](#):
>
> Only the first one showed up in the chart.

Because if this is you're exact code you're only adding `marker` to the chart, you just do so twice.

the last line should be:

```auto
chart.getPlot().addRangeMarker(marker1)

```

---

<div class="post-metadata">

**Author:** ![jfan](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jfan](https://forum.inductiveautomation.com/u/jfan)\
**Post date:** [June 12, 2023, 4:53pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/36 "2023-06-12T16:53:53Z")

</div>

I was doing some other tests and forgot to change it back. Changing the second one to marker1 actually gave me the same result.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 12, 2023, 5:22pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/37 "2023-06-12T17:22:23Z")

</div>

Are you _sure_ there's no errors in the console window?  
`configureChart` was silently failing with your exact script because I didn't have a data key named `average`. Once I changed those lines, it worked:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7e3e5eb2a1f43feddc637d2db7bb3d6b1d8a468f.png)

```python
def configureChart(data, chart):
	from org.jfree.chart.plot import ValueMarker
	marker = ValueMarker(4) #point on range axis to label
	label = 'Avg:'
	marker.setLabel(label)
	chart.getPlot().addRangeMarker(marker)
	
	marker1 = ValueMarker(8) #point on range axis to label
	label = 'Avg:'
	marker1.setLabel(label)
	chart.getPlot().addRangeMarker(marker1)

```

---

<div class="post-metadata">

**Author:** ![jfan](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jfan](https://forum.inductiveautomation.com/u/jfan)\
**Post date:** [June 12, 2023, 5:31pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/38 "2023-06-12T17:31:51Z")

</div>

It is now working for me as well. I am not exactly sure what I messed up. But appreciate the help!

---

<div class="post-metadata">

**Author:** ![Ayanakoji](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Ayanakoji](https://forum.inductiveautomation.com/u/Ayanakoji)\
**Post date:** [March 20, 2024, 2:38pm UTC](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/39 "2024-03-20T14:38:45Z")

</div>

when i add the color parameter the line is not showing, any reasons why? this is on reporting btw

def configureChart(data, chart):  
from org.jfree.chart.plot import ValueMarker  
from java.awt import Color  
red = Color(255, 10, 10)

```
marker = ValueMarker(0,red) #point on range axis to label
marker.setLabel("")
chart.getPlot().addRangeMarker(marker)

```

[Previous page](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445.md?page=1)
