Methods and properties to work with time graphs
Linear Trend is a type of graphic item that displays a time graph as one or several curves. One of the curves is main and it sets the apppearance of the whole trend.
Time axis - horizontal X axis. Date, the starting point (StartTime) and the ending point (EndTime) can be set. It allows to display history (archive) data on the trend. A trend can also keep track of coming curve values in real time and change display of all curves. In this case use .SetDynamic() method.
Download the example
Trend functions work with two projects: for the server (.sirpz file) and for a panel (.irpz file). The server gets a tag value and stores it in its database. A panel asks the server for data in a required time range and then displays them as a trend on the screen. Trend appearance is controlled in the script of a panel project (.irpz).
For projects to start successfully upload a server project to a real controller or a PC with launched iRidium server via iRidium transfer. A panel project can be uploaded to a real device or can be launched in the Emulator. Before launching a panel project set in it the correct IP address of the server:
sets the time range on the time axis of the trend and automatically assigns the utmost right point of the axis to the current time
IR.GetPage("Page 1").GetItem("Trend 1").SetDynamic(5/(24*60)); // range = 5 min
gives access to a trend curve and its settings.
var Curve1 = IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature");
var tomorrow = new iDate()-1;
var tomorrow_start = new iDate(tomorrow, tomorrow, tomorrow); // 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;
The property is applied only to the main curve of the trend.
For the trend to be displayed correctly, set XInterval several times shorter than the length of the time axis on the trend (EndTime - StartTime).
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature").XInterval=1/24; // one hour
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;