Trend
The trend shows tag values over time: history from the archive and live values, like the Trend view in WinCC. Pens come from a project trend group and/or are set on the element’s Pens tab: tag, source (archive or current value), color, scale, limits. The scale is common, per pen or in percent.
The operator has a toolbar: range, pause, paging, zoom, a ruler with values, range statistics, comparison with a past period, export to Excel and CSV. A script can do all of this too, with the actions below. See History and trends for more on trends and the archive.
Properties
Section titled “Properties”Besides the properties of every element — name, position, size, tooltip, rotation, transparency and the operate right:
| Property | Values | Default | Description |
|---|---|---|---|
Group |
trend group | Trend group. A pen set from the project “Trend groups”: colors, scales, interval. Pens from the “Pens” tab are added to the group | |
RangeMinutes |
integer | 60 |
Interval, min. How many minutes to show up to the current moment |
YMin |
number | Y axis from. Lower bound of the value scale, in tag units (e.g. 0). Empty — from data: the scale fits the visible values | |
YMax |
number | Y axis to. Upper bound of the value scale, in tag units (e.g. 100). Empty — from data | |
ShowLegend |
true / false |
true |
Legend |
ShowToolbar |
true / false |
true |
Toolbar. Interval, pause, zoom reset — for the operator |
Title |
text | Title | |
ScaleMode |
Common, PerPen, Percent |
Common |
Scale. Common — one axis; own — each pen has an axis in its color; percent — each pen in its own range. With a group — as in the group |
ShowPenTable |
true / false |
true |
Pen table. Below the chart: show/hide checkboxes, value at ruler, current, min/max/average |
ShowGrid |
true / false |
true |
Grid. Grid lines for time and values |
TimeFormat |
text | Time format. Time axis labels; empty — by interval | |
PlotBackground |
#RRGGBB |
Chart background. Empty — white |
From scripts
Section titled “From scripts”Item.Type = Trend. Any property is read and changed by name: Item.PlotBackground = "#D32F2F". The common element members (Visible, Enabled, Value, Raise, Apply…) are described in Elements from scripts.
Actions of this element:
| Member | Description |
|---|---|
Paused |
Whether it is paused (shows the archive, not the current moment) |
From |
Start of the visible range (Date) |
To |
End of the visible range (Date) |
Ruler |
Ruler time (Date); null — ruler hidden |
CompareHours |
Comparison offset in hours; null — no comparison |
Pause() |
Pause — the chart stops moving |
Live() |
Back to real time |
ShowLast(minutes) |
Real time for the last minutes: ShowLast(480) |
ShowRange(from, to) |
An archive range: ShowRange(“2026-11-26 08:00”, “2026-11-26 20:00”) or Date values |
Page(direction) |
Page by the window width: -1 back, 1 forward |
ResetView() |
Range, scales and real time from the settings |
SetRuler(time) |
Ruler at a moment; null removes it: SetRuler(new Date()) |
Pens() |
Pens — Tag, Title, Unit, Visible, Current, Min, Max, Average, AtRuler |
ShowPen(tag, visible) |
Show or hide a pen: ShowPen(“Tank1.Level”, false) |
Compare(hours) |
Compare with a past period as a dashed line: Compare(24) — a day ago; Compare(null) — off |
Export(format) |
Save the visible range to a file: Export(“xlsx”) or Export(“csv”) |
Events
Section titled “Events”Mouse, hover, focus and keyboard — as for any element (see Events and functions).
Examples
Section titled “Examples”A shift from 8:00 to 20:00 — a “Day shift” button shows an archive range.
var t = Screen.Items("Trend1");var d = new Date();t.ShowRange(new Date(d.getFullYear(), d.getMonth(), d.getDate(), 8), new Date(d.getFullYear(), d.getMonth(), d.getDate(), 20));The average over the visible range — for a shift report or a message.
var p = Screen.Items("Trend1").Pens()[0];HMI.ShowMessage(p.Title + ": average " + p.Average.toFixed(1) + " " + p.Unit + ", maximum " + p.Max.toFixed(1));Only the selected pump’s pen and a comparison with the same day a week ago.
var t = Screen.Items("Trend1");t.Pens().forEach(function (p) { t.ShowPen(p.Tag, p.Tag.indexOf(Tags("Pump.Selected").Value) === 0); });t.Compare(24 * 7);