Click or drag to resize

Adding/Removing Trends

The following code snippets can be used/modified to interact with the TrendGraph control.

Add Trends

C#
// get reference to trend graph control in current screen assuming there is a
// TrendGraph control named "TrendGraph1"
string trendGraphControlName = "TrendGraph1";
ControlTrendGraph trendGraph = Screen.ScreenControls[trendGraphControlName] as ControlTrendGraph;

// create trend control that we will add to the trend graph control
string controlName = null; // null will auto assign control name that is unique within the current screen
string sourceTag = "<server>view.tag";
ControlTrend trend = ControlFactory.CreateControl(ControlKind.Trend, controlName) as ControlTrend;
trend.SourceTag = sourceTag; // assign source tag used to determine what data to fetch when drawing trend

// add newly created trend to trend graph control children collection
trendGraph.Children.Add(trend);

Remove Trends

C#
// get reference to trend graph control in current screen assuming there is a
// TrendGraph control named "TrendGraph1"
string trendGraphControlName = "TrendGraph1";
ControlTrendGraph trendGraph = Screen.ScreenControls[trendGraphControlName] as ControlTrendGraph;

// get child trend control by control name
string childTrendControlName = "Trend1";
ControlTrend trend1 = trendGraph.Children[childTrendControlName] as ControlTrend;

// get child trend control by index
int childTrendControlIndex = 2;
ControlTrend trend2 = trendGraph.Children[childTrendControlIndex] as ControlTrend;

// get child trend control using linq
ControlTrend lastTrend = trendGraph.Children.Last() as ControlTrend;

// remove selected child trends from trend graph control
trendGraph.Children.Remove(trend1);
trendGraph.Children.Remove(trend2);
trendGraph.Children.Remove(lastTrend);

// remove all trends from trend graph control
trendGraph.Children.Clear();