GraphWorX64 Scripting - Interacting With A TrendWorX64 Viewer
GraphWorX64 Scripting - Interacting With A TrendWorX64 Viewer
Description: A scripting guide demonstrating how to interact Scroll down to the bottom of the References window and click in
with the TrendWorX64 Viewer control. the cell for Assembly Codebase in the last empty row. Click the
General Requirement: General knowledge of GraphWorX64 and button that will appear when you click in the cell. Browse to
its scripting capabilities; familiarity with the TrendWorX64 Viewer the following file and add it:
control.
C:/Program Files/ICONICS/GENESIS64/Components/
Introduction IcoDataConnector.DLL
C:/Program Files/ICONICS/GENESIS64/Components/
This guide will introduce you to writing scripts that interface with IcoCommonConnectors.DLL
the TrendWorX64 Viewer. It includes examples of how to add a
new pen, delete or modify an existing pen and toggle legend Add Pen script
using GraphWorX64 Scripting.
First we need to prepare the connection configuration, which
This document assumes that you have read the GraphWorX64 means what type of data source we want to connect and its
Scripting Quick Start application note. properties. In the following script we will define a connection to
TrendWorX64 Logger pen without any aggregates.
Preparing the display
var config : Ico.Data.DataConnector.UaSessionConfiguration;
config = new Ico.Data.DataConnector.UaSessionConfiguration();
To create this example we will need a display containing a config.PointName = "@ICONICS.TWXSQLSvr64.1\\Database Group.Logging
TrendWorX64 Viewer control with a plot. You will not be able to Group.Ramp.History";
config.UsageType = Ico.Data.DataConnector.UaSessionConfiguration.Usage.History;
add pens to your control unless it contains at least one plot. config.AggregateType = ""; // raw data
config.MaxSamplesForRawData = 125;
It is very important that the trend viewer control, chart and its
plot have unique names. Our scripts will use this name to Next we will create a new pen and will attach the above
identify which trend viewer to interact with (in case there is more connection configuration to it.
than one on a display). The names can be assigned in the
var pen : Ico.Twx.TwxChartPen = new Ico.Twx.TwxChartPen();
Advanced tab of the respective item.
pen.RangeAxis.ShowTitle = true;
pen.Name = "Pen1";
pen.Stroke = new SolidColorBrush(Colors.Blue);
pen.DataConnectionConfiguration = config.GetConfiguration();
The following code requires some extra references beyond the Finally we just add the pen.
defaults. To add these references, open the Script Editor and
series.Pens.Add(pen);
click on the Add References button on the left.
The code is complete. We can save our display, go to runtime
mode, then press the button add our new pen.
NOTE: Wait a moment if you do not see the pen immediately. It may
need a few seconds to begin drawing its line.
Copyright 2014 ICONICS, Inc. Page 1 of 2 GraphWorX64 Scripting - Interacting with a TrendWorX64 Viewer
GraphWorX64 Scripting
Interacting with a TrendWorX64 Viewer
August 2014
First we need to get a reference to our TrendWorX64 Viewer and Get reference to your control and chart.
the concerned pen.
var control : Ico.Twx.TwxViewControl = ThisDocument.GetElementByName("TWX"); var control : Ico.Twx.TwxViewControl = ThisDocument.GetElementByName("TWX");
var pen : Ico.Twx.TwxChartPen var chart: Ico.Twx.TwxChartComponent
pen = control.FindPen("Pen1"); chart = control.FindChartComponent("Chart1");
Next we may modify the properties such as color or stroke Toggle the legend visibility.
thickness in this example.
chart.ShowLegend = !chart.ShowLegend;
series.Pens.Remove(pen);
Copyright 2014 ICONICS, Inc. Page 2 of 2 GraphWorX64 Scripting - Interacting with a TrendWorX64 Viewer