# Dynamic Y axis range from the datasource on the XY Charg

**URL:** <https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 22, 2022, 7:44pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943 "2022-12-22T19:44:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 22, 2022, 7:44pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943/1 "2022-12-22T19:44:07Z")

</div>

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

Sometimes, I get this clipping effect that I want to eliminate.  
8.1.19

My thought is that I want to set the range as 0 and then {max(stops)} + 3,000 somehow.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9c6b4fee010189b3c8756049fd7d432123bd9110.png)

My datasource is a query binding.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbdbcbc0e423f3421d5a04b9965cb5f357c0740d.png)

I have had bad luck with self referencing bindings of properties before.  
So I wondered what the best way might be.

I can't set constants in the range because sometimes this query shows totals of many machines and sometimes just for one machine.

---

<div class="post-metadata">

**Author:** ![Eric\_Byrd](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/eric_byrd/32/43488_2.png) [@Eric\_Byrd](https://forum.inductiveautomation.com/u/Eric_Byrd)\
**Post date:** [December 30, 2022, 7:26pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943/2 "2022-12-30T19:26:28Z")

</div>

Hi Zachary,

By default, the XY chart should auto range. It is possible that other properties on your view could be affecting how your XY chart looks. I would need to see your view as a whole before making conclusions. You can always reach out to support and have us take a closer look with you that way.

If you want to use your own scaling instead, you can always bind your Y axis' max property to your data source and use a script transform to detect the max value in that dataset. From there you would just add 3000 to that value.

Here is an example of the script I used to test this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/2939890babfc72ecc88e7a27331d2487db2003f2.png)

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 30, 2022, 7:47pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943/3 "2022-12-30T19:47:48Z")

</div>

Thanks

That is so obvious now that you have shown me it.  
Thanks so much.

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [December 30, 2022, 8:04pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943/4 "2022-12-30T20:04:23Z")

</div>

A bit more pythonic....

```auto
return max(value, key=lambda x:x['process_temp']) + 3000

```

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 30, 2022, 8:07pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943/5 "2022-12-30T20:07:34Z")

</div>

The lambda confuses me. I had to relearn it multiple times. I think I need to start using lambda more to retain it.  
I think lambda is a kind of shorthand to look at all args.

* * *

I read lambda is like an anonymous function.  
Receives x, returns x['process\_temp'] from the value in this example.  
Thanks

> <https://stackoverflow.com/questions/13669252/what-is-lambda-in-python-code-how-does-it-work-with-key-arguments-to-sorte>

This helped me too.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [January 6, 2023, 4:36pm UTC](https://forum.inductiveautomation.com/t/dynamic-y-axis-range-from-the-datasource-on-the-xy-charg/67943/6 "2023-01-06T16:36:30Z")

</div>

~~I am getting an object is not iterrable error.~~

My datasource is bound to a query.  
I found in the manual in the datasets section, a way to get the value I needed.

* * *

```auto
data=value
this=data.getColumnAsList( data.getColumnIndex('Stops'))
return max(this)+3000

```
