You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ExportMethod]publicvoidAddPen(NodeIdpenId){// Get the variable that will be used as a penvartag=InformationModel.GetVariable(penId);// Create the pen objectvarpen=InformationModel.Make<TrendPen>(tag.BrowseName+"_pen");// Link the pen to the variablepen.SetDynamicLink(tag,DynamicLinkMode.ReadWrite);// Set the pen propertiespen.Color=Colors.Coral;pen.Thickness=3;// Add the pen to the trendtrend.Pens.Add(pen);// Refresh the trend to show the new pentrend.Refresh();}
Remove a pen from a trend
/// <summary>/// Remove Trend pens at runtime using ComboBoxes to select DataLogger and Variable./// </summary>[ExportMethod]publicvoidRemovePen(){// Remove a pen from a trend by namevarnameCombo=Owner.Owner.Get<ComboBox>("ComboBox1");varmyTrend=Owner.Owner.Owner.Owner.Get<Trend>("Trend1");myTrend.Pens.Remove(((UAManagedCore.LocalizedText)nameCombo.SelectedValue).Text);}
Y-axis
Add a Y-axis to a pen
FactoryTalk Optix version 1.7.1.x and later
[ExportMethod]publicvoidAddYAxisToPen(){// Get the pen to interact withvartrend=Owner.Get<Trend>("Trend1");// Get the pen and add a Y-axis to itvarpen=trend.Pens.Get<TrendPen>("Variable1_pen");varnewAxis=pen.GetOrAddYAxis();// Set the Y-axis propertiesnewAxis.MinValue=0;newAxis.MaxValue=100;// Refresh the trend to show the new Y-axistrend.Refresh();}
FactoryTalk Optix before version 1.7.1.x
[ExportMethod]publicvoidAddYAxisToPen(){// Get the pen and the Y-axisvartrend=Owner.Get("Trend1")asTrend;varpen=trend.Pens.Get<TrendPen>("TrendPen1");// Create a new Y-axisvaruiNamespaceIndex=NamespaceMapProvider.GetNamespaceIndex("urn:FTOptix:UI");varyAxis=InformationModel.Make<FTOptix.UI.ValueAxis>(newQualifiedName(uiNamespaceIndex,"YAxis"));// Set the Y-axis propertiesyAxis.MinValueVariable.Value=-10;yAxis.MaxValueVariable.Value=42;yAxis.PositionVariable.Value=0;// 0 = left, 1 = right// Assign the Y-axis to the penpen.Add(yAxis);}
Remove a Y-axis from a pen
FactoryTalk Optix version 1.7.1.x and later
[ExportMethod]publicvoidRemoveYAxisFromPen(){// Get the pen to interact withvartrend=Owner.Get<Trend>("Trend1");// Get the pen and remove its Y-axisvarpen=trend.Pens.Get<TrendPen>("Variable1_pen");pen.RemoveYAxis();// Refresh the trend to show the changetrend.Refresh();}
FactoryTalk Optix before version 1.7.1.x
[ExportMethod]publicvoidRemoveYAxisFromPen(){// Get the pen and its Y-axisvartrend=Owner.Get("Trend1")asTrend;varpen=trend.Pens.Get<TrendPen>("TrendPen1");varyAxis=pen.Children.OfType<FTOptix.UI.ValueAxis>().FirstOrDefault();// Remove the Y-axis from the penif(yAxis!=null)pen.Remove(yAxis);}