# Show an operating range in the vision chart

**URL:** <https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [August 19, 2022, 3:29pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207 "2022-08-19T15:29:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrautomation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/vrautomation/32/11155_2.png) [@vrautomation](https://forum.inductiveautomation.com/u/vrautomation)\
**Post date:** [August 19, 2022, 3:29pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/1 "2022-08-19T15:29:07Z")

</div>

Hello 🙂  
How can I show an operating range in a chart? Actually I’m using 2 horizontal lines, but I would like to color this area instead.

Thanks.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/3585855bb17fe08792b6270aef724dff9f66f7ab.png)

---

<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:** [August 19, 2022, 5:44pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/2 "2022-08-19T17:44:29Z")

</div>

In theory, something like this script to add a ValueMarker:

> [@Bar chart (report) static line](https://forum.inductiveautomation.com/t/bar-chart-report-static-line/18445/2):
>
> Untested, but you would need something like this in the chart configuration script: from org.jfree.chart.plot import ValueMarker marker = ValueMarker(123) #point on range axis to label marker.setLabel("Some Marker") chart.getPlot().addRangeMarker(marker)

But you want to use the IntervalMarker class instead:  
[https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/IntervalMarker.html](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/IntervalMarker.html)

---

<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 22, 2022, 7:26am UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/3 "2022-08-22T07:26:52Z")

</div>

I played around with PGriffith’s suggestion, and I was able to get it to work.

Put this code in the actionPerformed event handler of a button, and it will give you exactly what your asking for:

```auto
from java.awt import BasicStroke
from org.jfree.chart.plot import ValueMarker
lowRange = 10
highRange = 20
centerOfRange = (lowRange+highRange)/2
totalRange = 4*(highRange-lowRange)
event.source.parent.getComponent('Chart').chart.plot.addRangeMarker(ValueMarker(centerOfRange, system.gui.color(20, 10, 10, 40), BasicStroke(totalRange)))

```

If you need this to happen automatically, perhaps fire it from the internalFrameOpened even handler of the parent window

---

<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 22, 2022, 10:01am UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/4 "2022-08-22T10:01:57Z")

</div>

I kept exploring the other related Java options, and I found that I was able to get the same effect with the IntervalMarker extension. The result is exactly the same, but the code is a little bit simpler:

```auto
from org.jfree.chart.plot import IntervalMarker
lowSetPoint = 10
highSetPoint = 20
event.source.parent.getComponent('Chart').chart.plot.addRangeMarker(IntervalMarker(lowSetPoint, highSetPoint, system.gui.color(20, 10, 10, 40)))

```

---

<div class="post-metadata">

**Author:** ![patrick.maltais](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/patrick.maltais/32/3958_2.png) [@patrick.maltais](https://forum.inductiveautomation.com/u/patrick.maltais)\
**Post date:** [August 31, 2022, 3:05pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/5 "2022-08-31T15:05:11Z")

</div>

@justinedwards.jle you mentionned using the internalFrameOpened event handler for automatic config. How about using the Chart’s configureChart Extension Function ? I tried it but nothing happens. Can someone explain why? Maybe I misinterpreted the purpose of this function?

“”"  
Provides an opportunity to perform further chart configuration via  
scripting. Doesn’t return anything.

```
Arguments:
	self: A reference to the component that is invoking this function.
	chart: A JFreeChart object. Refer to the JFreeChart documentation for
	       API details.

```

“”"

Knowing that the range must be applied to the second subplot, here is the code used:

```auto
	from org.jfree.chart.plot import IntervalMarker
	lowSetPoint = self.parent.AccumulatorWindowLow
	highSetPoint = self.parent.AccumulatorWindowHigh
	subplot = self.getChart().getPlot().getSubplots()[2]
	subplot.addRangeMarker(IntervalMarker(lowSetPoint, highSetPoint, system.gui.color(255,127,39, 50)))

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 31, 2022, 3:10pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/6 "2022-08-31T15:10:33Z")

</div>

> [@patrick.maltais](#):
>
> `subplot = self.getChart().getPlot().getSubplots()[2]`

Try using the `chart` object _supplied_ to the routine (and using jython optimized property access):

```auto
subplot = chart.plot.subplots[2]

```

---

<div class="post-metadata">

**Author:** ![patrick.maltais](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/patrick.maltais/32/3958_2.png) [@patrick.maltais](https://forum.inductiveautomation.com/u/patrick.maltais)\
**Post date:** [August 31, 2022, 3:13pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/7 "2022-08-31T15:13:17Z")

</div>

> [@pturmel](#):
>
> `subplot = chart.plot.subplots[2]`

Thanks @pturmel. It's working now!

---

<div class="post-metadata">

**Author:** ![vrautomation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/vrautomation/32/11155_2.png) [@vrautomation](https://forum.inductiveautomation.com/u/vrautomation)\
**Post date:** [August 31, 2022, 3:32pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/8 "2022-08-31T15:32:50Z")

</div>

I really love this forum and the Ignition’s community. Thanks everyone!

---

<div class="post-metadata">

**Author:** ![patrick.maltais](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/patrick.maltais/32/3958_2.png) [@patrick.maltais](https://forum.inductiveautomation.com/u/patrick.maltais)\
**Post date:** [August 31, 2022, 3:52pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/9 "2022-08-31T15:52:45Z")

</div>

Interresting fact I want to share with the community. In our solution the range can change over time. We implemented event handlers on the value of the range’s min and max. If you keep adding ranges over time, colors will also add on top of the others.The range can become opaque even if you want to keep it with a certain level of transparency.  
Consider calling `.clearRangeMarkers()` before calling `.addRangeMarker(...)`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 31, 2022, 4:51pm UTC](https://forum.inductiveautomation.com/t/show-an-operating-range-in-the-vision-chart/63207/10 "2022-08-31T16:51:56Z")

</div>

When called from within `configureChart` it is always a new chart object. No accumulating markers. To accommodate changing ranges, you can subclass the appropriate marker to look up the values in your custom properties every time it is asked instead of supplying a constant in the standard marker.
