# How to pass value dynamically to upper margin in chart

**URL:** <https://forum.inductiveautomation.com/t/how-to-pass-value-dynamically-to-upper-margin-in-chart/42647>\
**Category:** Ignition\
**Created:** [January 27, 2021, 11:18am UTC](https://forum.inductiveautomation.com/t/how-to-pass-value-dynamically-to-upper-margin-in-chart/42647 "2021-01-27T11:18:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [January 27, 2021, 11:18am UTC](https://forum.inductiveautomation.com/t/how-to-pass-value-dynamically-to-upper-margin-in-chart/42647/1 "2021-01-27T11:18:58Z")

</div>

Hi, how to pass value dynamically to upper margin percentage in chart. I have tired many ways. But I can’t able to pass value to the upper margin dynamically. Please any one knows let me know

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 28, 2021, 5:42pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-value-dynamically-to-upper-margin-in-chart/42647/2 "2021-01-28T17:42:48Z")

</div>

This requires digging down into the chart object itself.  
Assuming one plot and one defined axis (otherwise, you would need to use an index number for each).

```python
# Get the chart component object
component = event.source.parent.getComponent('Chart')

# Get chart data
chart = component.getChart()

# Get the plot settings
plot = chart.getPlot()

# Get the axis settings
axis = plot.getRangeAxis()

# Now that we have the axis, we can set different things. 

# Set the upperMargin
axis.setUpperMargin(0.5)

# Turn off auto range
axis.setAutoRange(0)

# set upper and lower bounds
axis.setUpperBound(1000)
axis.setLowerBound(500)

```
