Trend example with Y axis change

<< Click to Display Table of Contents >>

Navigation:  Examples > Trends >

Trend example with Y axis change

Previous pageReturn to chapter overviewNext page

In the previous example, we could set the trend time range (X-axis) arbitrarily by clicking on it with the mouse and specifying the “Start” and “End” of the period in the pop-up window:

 

selectdateandtime

 

If we want to change the range of the Y axis we need to use a script.

Let's take the project from our previous example as a basis, where a tag and a graphic object have already been created and configured.

 

1. Let's create an intermediate tag named max, which will change the maximum trend range (Y-axis) through a script:

 

maxtag

 

2. To set the value for the Y axis of the Trend DB, place a Slider on the screen and bind the max tag to it through the “Control” property:

 

slidercontrol

 

3. We will also bind the value of the max tag to the maximum property of the Trend using the ST script. Let's create a script that will be called when the value of the max tag changes:

 

maxscript

 

Let's write a script:

 

maxscripttext

After you have recorded the script, be sure to launch it by clicking the button on the toolbar: runsimulation

 

4. Let’s Run simulation to check the settings (using the slider we will set the value for the Y-axis of the Trend):

 

 

trendaxisy

 

You can download this project here.