Follow

How can I specify date/time axes limits in Grapher via automation?

This article contains a sample script for using the DateValue BASIC automation command to specify date/time axes limits.

To run this script:

  1. Click here to download the BAS file: DateTimeAxesLimits.BAS.
  2. Click Automation | Scripts | Run, select the BAS file from your downloads directory, and click Open.

OR:

  1. Copy the script below.
  2. Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
  3. Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
  4. Press Ctrl+V to paste it into the Script Manager.
  5. Click the Start/Resume icon () in the Script Manager. 

Sub Main

'Initialize Grapher
Dim Grapher As Object
Set Grapher = CreateObject("Grapher.Application")
Grapher.Visible = True
Set Plot1 = Grapher.Documents.Add(grfPlotDoc)
Plot1.Windows.Item(1).PageUnits(grfInches)

'Create line plot graph
Plot1.Shapes.AddLinePlotGraph("C:\Program Files\Golden Software\Grapher 14 Preview\Samples\3D bar chart.dat",1,2)

'Define object pointers
Set Graph1 = Plot1.Shapes.Item(1)
Set YAxis1 = Graph1.Axes.Item(2)
Set XAxis1 = Graph1.Axes.Item(1)
Set LineScatterPlot1 = Graph1.Plots.Item(1)

'Set TickLabels.UseDateTimeFormat
XAxis1.TickLabels.UseDateTimeFormat = True

'Set Min
XAxis1.AutoMin = False
XAxis1.Min = DateValue("7/2/1905")

'Set Clipping.XMinMode
LineScatterPlot1.Clipping.XMinMode = grfClipAxis

End Sub

Updated December 7, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.