Writing scripts > Manipulating charts

Additional chart functions

Changing the Chart Duration

The following script specifies a ten-minute chart:

Chart1.Duration = 600

You can also use the following:

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

The end time will be calculated as the start time plus the duration. If you are using historical pens, you can fetch the data again by using:

Chart1.RefreshChartData

Changing the Start and End Times

To set the start time in your chart to Oct.31 at 12:30, enter the following script:

Chart1.StartTime = #10/31/98 12:30:00 PM#

The end time is calculated as the start time plus the duration.

Or use:

Chart1.EndTime = #10/31/98 12:30:00 PM#

The start time is calculated as the end time minus the duration.

If you are using historical pens, you can fetch the data again by using:

Chart1.RefreshChartData

Zooming

If the chart is selectable, you may use the mouse to enclose an area in the chart to zoom to in a rectangle selector. Alternately, you can use scripts to set the pen Hi and Lo limits to zoom:

'Original limits are 0 to 100, but data is fluctuating 
'between 60 and 80.
Pen1.HiLimit = 85
Pen1.LoLimit = 55

'To zoom back out:
Pen1.HiLimit = 100
Pen1.LoLimit = 0

'The following method has the same effect:
Chart.ResetToOriginal

'Or you can also call this method, which would set the 
'HI limit to 80 and the LO Limit to 60:
Chart1.AutoScaleDisplayLimits

Pausing a Real-Time Chart

If you are using real-time pens, you may want to pause the display to examine data. To do this, use the following script:

Chart1.Pause
'Now, to Resume:
Chart1.Resume

'There is a timeout associated with the Pause/Resume such 
'that if the chart is paused for longer than the timeout,
'the chart will automatically resume.  For example, to
'restart the chart after a minute:
Chart1.Timeout = 60
Chart1.Pause

Using the Refresh Chart Data

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

Keyboard Accelerators for Charts

The following keyboard accelerators are available to a selectable chart:

Keyboard Accelerator

Default Purpose

Ctrl + Left Arrow

Moves the time cursor one pixel to the left.

Ctrl + Right Arrow

Moves the time cursor one pixel to the right.

Shift + Ctrl + Left Arrow

Moves the time cursor ten pixels to the left.

Shift + Ctrl + Right Arrow

Moves the time cursor ten pixels to the right.

Ctrl + Up Arrow

Selects the next pen to be the current pen.

Ctrl + Down Arrow

Selects the previous pen to be the current pen.