# Adding a constant value on a Report's TimeSeriesChart with a refresh

**URL:** <https://forum.inductiveautomation.com/t/adding-a-constant-value-on-a-reports-timeserieschart-with-a-refresh/93478>\
**Category:** Ignition\
**Tags:** ignition81, vision, reporting\
**Created:** [July 19, 2024, 4:14pm UTC](https://forum.inductiveautomation.com/t/adding-a-constant-value-on-a-reports-timeserieschart-with-a-refresh/93478 "2024-07-19T16:14:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 19, 2024, 4:14pm UTC](https://forum.inductiveautomation.com/t/adding-a-constant-value-on-a-reports-timeserieschart-with-a-refresh/93478/1 "2024-07-19T16:14:59Z")

</div>

I have a basic report setup with a script that adds a red constant value to a timeseries chart.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/142cf8e4d3c04259531f267edae13060596c2fb4.png)

If I change the start time of the report to 10:01 AM the following is shown:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37f087a1e3d63e30e26c7f2715dca18ae19aa842.png)

but if I change the start time to 10:03 AM the following incorrect is shown:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/7/470c3170f79a94e25c86119ccc03355e7a43dff1.png)

The problem i presume is the data range no longer includes the constant value. Is there a way to set the Y-axis to always include the constant value even if the actual data isn't within that range?

This is the script I have to add the constant line to the timeserieschart currently.

```python
from java.awt import Color
from java.awt import BasicStroke;
from org.jfree.chart.plot import ValueMarker
	
red = Color(255, 0, 0)
stroke = BasicStroke(2.0)
	
marker = ValueMarker(126, red, stroke)

chart.getPlot().addRangeMarker(marker)
```

---

<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:** [July 19, 2024, 5:00pm UTC](https://forum.inductiveautomation.com/t/adding-a-constant-value-on-a-reports-timeserieschart-with-a-refresh/93478/2 "2024-07-19T17:00:28Z")

</div>

I think you just want to reach into your axis (`plot.rangeAxis`, probably) and give it an explicit minimum value, maybe 125.5?

[https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/ValueAxis.html#setAutoRangeMinimumSize-double-](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/ValueAxis.html#setAutoRangeMinimumSize-double-)

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 19, 2024, 5:44pm UTC](https://forum.inductiveautomation.com/t/adding-a-constant-value-on-a-reports-timeserieschart-with-a-refresh/93478/3 "2024-07-19T17:44:14Z")

</div>

This did the trick.

```python

chart.getPlot().getRangeAxis().setLowerBound(126)

```

---

<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:** [July 19, 2024, 5:46pm UTC](https://forum.inductiveautomation.com/t/adding-a-constant-value-on-a-reports-timeserieschart-with-a-refresh/93478/4 "2024-07-19T17:46:36Z")

</div>

I would replace the range axis with one that dynamically computed its upper/lower range from the data and any auxiliary values whenever it is asked for upper/lower.

I vaguely recall doing this at one point to deal with Vision's classic chart not calling `configureChart()` after fresh data arrives. But I only found this:

> [@Change background color of vision chart](https://forum.inductiveautomation.com/t/change-background-color-of-vision-chart/73322/8):
>
> Sure. I have this in a chart\_util library script: from org.jfree.chart.plot import ValueMarker from java.awt import Color, BasicStroke # # Supply a function to obtain the range value to mark with the given # color and stroke. class DynValueMarker(ValueMarker): def \_\_init\_\_(self, callable, clr, stroke): super(ValueMarker, self).\_\_init\_\_(0.0, clr, stroke) self.callable = callable def getValue(self): return self.callable() You apply the above in configureChart with a function that reads …

The technique for delegating range requests to other data instead of constants would be similar to that dynamic range marker.
