iRidi API. Trends (Trend)
Linear Trend is a graphic item type (Item) that displays a time graph with one or more curves. One curve is the main curve and determines the appearance of the whole trend.
The time axis is the horizontal X axis. Set its starting date and time (StartTime) and ending date and time (EndTime) to display historical (archived) data. A trend can also follow incoming curve values and redraw all curves in real time; use .SetDynamic() for this.
Example
Trend functionality uses two projects: a server project (.sirpz) and a Panel Project (.irpz). The server receives tag values and stores them in its database. The panel requests data for the required time range and displays it as a trend. A script in the Panel Project (.irpz) controls trend display.
To run the projects successfully, upload the server project with iRidi Transfer to a physical controller or a computer running iRidi Server. Upload the Panel Project to a physical device or run it in the emulator. First set the correct server IP address in the Panel Project:

Linear Trend object methods
.SetDynamic()
Sets the trend's time range and permanently binds the rightmost point of the time axis to the current time.
Syntax
.SetDynamic(range);
| Input | Value | Description |
|---|---|---|
| range | 1.0 | type: number time range in days in the format iDate |
| Output | ||
|---|---|---|
| - |
Example
`IR.GetPage("Page 1").GetItem("Trend 1").SetDynamic(5/(24*60)); // range = 5 min`
.GetCurve()
Provides access to a trend curve and its settings.
Syntax
.GetCurve(name);
| Input | Value | Description |
|---|---|---|
| name | "Curve 1" | type: string name of the curve to access |
| Output | ||
|---|---|---|
| - | [ ] | type: object curve object |
Example
`var Curve1 = IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature");`
.GetCurve().SetCurveTag()
.SetCurveTag() specifies the variable to plot on a trend curve. First access the curve with .GetCurve()
Syntax
.GetCurve(name).SetCurveTag(path);
| Input | Value | Description |
|---|---|---|
| name | "Drivers.Modbus.Register 12" | type: string full variable name (see examples in Relations under the item's Programming panel) |
| Output | ||
|---|---|---|
| - |
Example
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Setpoint").SetCurveTag("Drivers.iRidi Server.KNX.1/4/1");
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Current").SetCurveTag("Drivers.Modbus.Register 12");
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Fan speed").SetCurveTag(""); // clear
Linear Trend object properties
.StartTime
| StartTime | 43259.4621924 | type: number Date and time of the starting point on the trend's time axis in the format iDate. |
.EndTime
| EndTime | 43260.4621924 | type: number Date and time of the ending point on the trend's time axis in the format iDate. |
var tomorrow = new iDate()-1;
var tomorrow_start = new iDate(tomorrow[0], tomorrow[1], tomorrow[2]); // midnight time 00:00:00.000
IR.GetPage("Main_page").GetItem("Trend").StartTime = tomorrow_start;
IR.GetPage("Main_page").GetItem("Trend").EndTime = tomorrow_start+1;
Curve properties
.XInterval
| XInterval | 365.0 | type: number Time interval in days between labels on the time axis in the format iDate. |
- This property applies only to the trend's main curve.
- For a tidy trend display, XInterval must be several times smaller than the trend's time-axis length (EndTime - StartTime).
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature").XInterval=1/24; // one hour
.XLabelTemplate
| XLabelTemplate | "%yy/%mm/%dd" | type: string Date and time label format on the time axis. |
This property applies only to the trend's main curve.
var time = "%hh:%nn:%ss.%ms"; // hh:mm:ss.ms format
var date = "%dd.%mm.%yy"; // dd.mm.yyyy format
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature").XLabelTemplate = time + " " + date;