GE Intelligent Platforms > Support >  KB > KB1402
Dynamics iFIX Chart Object Tip Sheet
Description

Description

Dynamics iFIX Chart Object Tip Sheet

Resolution


The Pens Collection
The pens contained in the chart are exposed in a collection called Pens. If you are constantly adding and deleting pens, writing specific scripts which operate on those pens may become cumbersome. An alternative way of writing your scripts is to not access say, Pen3, but to access Chart.Pens.Item(3). The order of the pens in this collection is the order that the pens appear in the Pen list in the UI and in the legend. This is actually the recommended way of working with pens. Using the collection will also allow you to avoid any problems deleting pens that have scripts explicitly referencing them. See "Deleting a Pen".

Adding a Pen
Chart.AddPen("Fix32.NODE.TAG.F_CV") will add a new pen to a chart. In config mode, adding a pen will grow the chart by the height of the legend line. In run, for object positioning reasons, the chart does not grow, but instead, the plot area will shrink.

Deleting a Pen
If you have a chart with 3 pens and wish to delete the second pen use
Chart1.DeletePen(2)

If deleting pens through automation, the delete will fail if there is a script referencing the name of the pen you are trying to delete.

For example:

Pen2.PenLineColor = 255
Chart1.DeletePen(2)

The delete call will fail because there is a script explicitly using Pen2. Instead, use:

Private Sub Rect2_Click()
Dim pPen As Object
Set pPen = Chart1.Pens.Item(2)
pPen.PenLineColor = 255
Chart1.DeletePen (2)
End Sub

See "The Pens Collection" for more info.

Also, if you delete all of your pens in run mode, you will see a blank chart. Popping up the UI will re-add a default pen, or you can just use the AddPen method to add a pen.

If you are deleting a pen, and are just going to add another, we recommend just changing the pen source via Pen.Source = "Fix32.Node.Tag.f_cv" for performance reasons (see "Changing Pen Sources").


Changing Pen Sources
If you have a process variable, PumpTemp1 (AI) which is also the input tag for PumpTemp1-History (ETR storing an hour of data), and you are also historically collecting PumpTemp1. It may be very helpful to view the different data associated with PumpTemp1. You may have a 3 buttons to view the different data:

�Real-time
Private Sub Rect2_Click()
Pen1.Source = "Fix32.Area1.PumpTemp1.F_CV"
End Sub

�Trend History
Private Sub Rect3_Click()
Pen1.Source = "Fix32.Area1.PumpTemp1-History.T_DATA"
End Sub

�Historical
Private Sub Rect4_Click()
Pen1.Source = "Hist.Area1.PumpTemp1.F_CV"

'Now set the start time and fetch
Pen1.StartTime = #10/31/98 11:30:00 AM#
Chart1.RefreshChartData
End Sub

This will allow you to easily switch between different types of data. If you do not care whether the data source exists or not, use Pen.SetSource("DataSource", TRUE).

Passing in external data to the pen
Keep in mind that the data doesn�t have to be from SQL; it may be any external data. The call used is Pen.SetPenDataArray.

Private Sub Rect2_Click()
Dim wrkSpace As Workspace
Dim db_var_name As Database
Dim record_var As Recordset

'open up the database and the named query
Set wrkSpace = CreateWorkspace("", "admin", "", dbUseJet)
Set db_var_name = wrkSpace.OpenDatabase("c:\winnt\ ChartData.mdb")
Set record_var = db_var_name.OpenRecordset("Data Query", dbOpenDynaset)

'get the number of records in the set
Dim count As Long
record_var.MoveLast
count = record_var.RecordCount
record_var.MoveFirst

Dim row As Integer
Dim col As Integer
Dim value(500) As Double
Dim times(500) As Date
Dim quality(500) As Long
Dim i As Integer

'loop through and get the data from the record
For i = 0 To count - 1
value(i) = record_var.Fields("Value").value
times(i) = record_var.Fields("Time").value
quality(i) = record_var.Fields("Quality").value
record_var.MoveNext
Next i
db_var_name.Close

Dim vtVal As Variant
Dim vtDate As Variant
Dim vtQual As Variant
Dim res As Integer

'set up correct array types
vtVal = value
vtDate = times
vtQual = quality

'call the pen with the data arrays
Pen2.SetSource("MySQLData", TRUE).
res = Pen2.SetPenDataArray(count, vtVal, vtDate, vtQual)

End Sub

T_DATA field of Trend and Extended Trend blocks
In the chart, the T_DATA field has replaced the G_DATA field for trend history data. Instead of:

Pen.Source = "Fix32.NODE.ETR1.G_DATA"you will now use
Pen.Source = "Fix32.NODE.ETR1.T_DATA".


Changing the duration
�make a 10 minute chart
Chart1.Duration = 600

Or,
Chart1.SetDuration (0, 0, 10, 0)

The end time will be calculated as the StartTime + Duration

If you are using HTR pens, in order to refetch the data,

Chart1.RefreshChartData

must be called.


Changing the Start/EndTimes
�Set the start time to Oct.31 at 12:30
Chart1.StartTime = #10/31/98 12:30:00 PM#
The end time will be calculated as the StartTime + the duration

Or,
�Set the End Time to be Oct.31 at 12:30
Chart1.EndTime = #10/31/98 12:30:00 PM#
The StartTime will be calculated as the EndTime - Duration

If you are using HTR pens, in order to refetch the data,

Chart1.RefreshChartData

must be called.

Scrolling HTR data
To scroll chart data, use Chart.ScrollForward or Chart.ScrollBack. These methods change the start and end times based upon Chart.ScrollPercentage. If your duration is 1 minute and the ScrollPercentage is 50, the chart will scroll by 30 seconds.

RefreshChartData
When using HTR pens, if any of the time parameters are changed (StartTime, EndTime, Duration) Chart.RefreshChartData must be called in order to fetch the new data. If you are using ScrollForward and ScrollBack, calling RefreshChartData is not necessary.


ApplyToAll
In the ChartUI, there is an ApplyToAll checkbox. If checked, upon hitting OK, selecting a Pen from the list, or hitting Apply, the properties will be set in each pen in the chart. If not checked, the properties will only be set in the selected pen.

Chart v. Pen Properties
You will notice that there are some pen level properties (or axis, legend, grid) that are exposed at the chart level as well. These are provided as convenience functions to allow the set of all pens with one call. In some cases, the chart property will reflect the value of the CurrentPen. Please keep in mind that if you have customized the properties of one of the pens, setting one of these properties through the Chart will overwrite any previous changes. The properties that fall under this category are:

DaysBeforeNow, Duration, EndTime, FixedDate, FixedTime, GetDuration, GetInterval, GetTimeBeforeNow, HorizontalGridColor, HorizontalGridStyle, Interval, NumberofHorizontalGridLines, NumberofVerticalGridLines, ScrollBack, ScrollForward, SetDuration, SetInterval, SetTimeBeforwNow, ShowDate, ShowHorizontalGrid, ShowVerticalGrid, ShowLegend, ShowTimeAxis, ShowValueAxis, StartTimeMode, ShowTimeAxisTitle, ShowValueAxisTitle, StartDateMode, StartTime, TimeAxisNumLabels, ValueAxisNumLabels, TimeAxisNumTicks, ValueAxisNumTicks, TimeAxisTitle, ValueAxisTitle, VerticalGridColor, VerticalGridStyle.

Zooming
Zooming can be done via the mouse. If you wish to only zoom in on the time axis, set ZoomDirection to Horizontal. Set it to Vertical to zoom in only on the value axis. Setting the Hi and Lo limits and the duration in run mode are also alternative ways to zoom.

Selectable and Modifiable
If the chart is selectable, users will be able to zoom and select pens (via clicking the legend). If the chart is modifiable, double-clicking the chart will bring up the chart UI. If you wish to display a custom UI, you can Show a UserForm in the Chart�s OnEdit event.

AutoRefresh
To AutoRefresh Chart data, insert a Timer into the picture. In the Timer�s Timeout event, use either ScrollForward or ScrollBack, or set the Start/End time of the chart.

Time Properties
TimeBeforeNow, DaysBeforeNow, FixedTime, FixedDate, StartTimeMode, StartDateMode are used to determine the initial time configuration of an HTR pen. They are the same as the 6.x product. Once in run mode, use StartTime or EndTime to change the time config.






ProductVersionModule
HMI/SCADA - iFIX VersionsVBA-General


Details
ID: KB1402
Legacy ID: i013242
Category: Articles
Last Updated: 11/15/01
Date Created: 01/17/00
Status: Published
Attachments: No
Language: English
User Group: All


 


Overall Rating: 3 (4 responses)
Rate this content record (1=lowest, 5=highest)
5
4
3
2
1
Comment