# How to set (pass) a dynamic value for lower and upper ranges of Y-Axis in chart

**URL:** <https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [January 8, 2025, 8:13am UTC](https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570 "2025-01-08T08:13:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MUNIYANDI\_D](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@MUNIYANDI\_D](https://forum.inductiveautomation.com/u/MUNIYANDI_D)\
**Post date:** [January 8, 2025, 8:13am UTC](https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570/1 "2025-01-08T08:13:59Z")

</div>

Hi..

I'm Using a Chart to show the trend of some values, such as current, voltage, etc. Each of the parameters has a Minimum and Maximum value. So, I show the minimum and maximum values as straight lines, and the actual values are shown as normal grids. I'll add the reference image below. Sometimes the actual values could be less than the minimum values and Sometimes greater than the Maximum value. But we need to Show the Exact values between the maximum and minimum values. That's why I wrote a script in the ConfigureChart extension function.

```python
def configureChart(self, chart):

	if self.parent.getComponent('Group').getComponent('CheckBox').selected == True:
		chart.plot.rangeAxis.setAutoRange(False)
		chart.plot.rangeAxis.setLowerBound(float(self.parent.parent.graph_1_min))
		chart.plot.rangeAxis.setUpperBound(float(self.parent.parent.graph_1_max))
    
	else:
		chart.plot.rangeAxis.setAutoRange(True)

```

In this code, I set the lower and Upper Bound values of the Y-axis, and those values are also updated in the Chart Customizer. But now populate in the Chart component. Whenever I click that chart and select some areas in the Chart panel, the changes have been updated. Otherwise, the changes couldn't be updated. And I tried to refresh that component, but that also not working. Could anyone can help me to find out the solution to this?

Thanks,  
Muniyandi D

---

<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:** [January 8, 2025, 1:24pm UTC](https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570/2 "2025-01-08T13:24:36Z")

</div>

The Classic Chart component doesn't run `configureChart` for data changes. The proper solution is to use customized `ValueMarker` instances that look at your custom props every time they are asked for their value, and to replace the range axis with a custom Axis that does similar with your bounds.

See this topic for inspiration:

> [@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 …

---

<div class="post-metadata">

**Author:** ![MUNIYANDI\_D](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@MUNIYANDI\_D](https://forum.inductiveautomation.com/u/MUNIYANDI_D)\
**Post date:** [January 9, 2025, 7:09am UTC](https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570/3 "2025-01-09T07:09:20Z")

</div>

Sorry, @pturmel. That slightly confuses me because they are changing the plot color. But my wish is to change or refresh the plot to populate that data into the chart. I also have one checkBox component that enables and disables the ranges. The Max, Min, and Target range lines should be shown when the CheckBos has been enabled. Once the CheckBox has been disabled the Min, Max, And Target lines should be disappeared. I have Completed this part. But that data only not populating In the chart. Could you give an example of it? That would be helpful for me.

Thanks,  
Muniyandi

---

<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:** [January 9, 2025, 8:42am UTC](https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570/4 "2025-01-09T08:42:41Z")

</div>

The result you're looking for could be achieved by running this from the `propertyChange` event handler of the **check box** component instead of the `configureChart` extension function of the chart:

**Example:**

```python
if event.propertyName == 'selected':
	chart = event.source.parent.parent.getComponent('Chart').chart
	if event.newValue:
		chart.plot.rangeAxis.setAutoRange(False)
		chart.plot.rangeAxis.setLowerBound(float(event.source.parent.parent.graph_1_min))
		chart.plot.rangeAxis.setUpperBound(float(event.source.parent.parent.graph_1_max))
	    
	else:
		chart.plot.rangeAxis.setAutoRange(True)

```

---

<div class="post-metadata">

**Author:** ![MUNIYANDI\_D](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@MUNIYANDI\_D](https://forum.inductiveautomation.com/u/MUNIYANDI_D)\
**Post date:** [January 9, 2025, 11:00am UTC](https://forum.inductiveautomation.com/t/how-to-set-pass-a-dynamic-value-for-lower-and-upper-ranges-of-y-axis-in-chart/100570/5 "2025-01-09T11:00:21Z")

</div>

Thank you @justinedwards.jle for your kind support and suggestions. This method has worked well... 🥳

Thanks ,  
Muniyandi D
