Follow

How can I use a script to check which rows in Grapher are being used for my labels?

This article contains a sample script for creating a graph, returning and setting the rows used for plotting labels.

To run this script:

  1. Click here to download the BAS file: rowlabels.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
Dim GrapherApp As Object
Set GrapherApp = CreateObject("Grapher.Application")
GrapherApp.Visible = True

Set Plot = GrapherApp.Documents.Add(grfPlotDoc)
Set Shapes = Plot.Shapes
Set LineGraph = Shapes.AddLinePlotGraph(GrapherApp.Path+"\samples\tutorial.dat")
Set LinePlot = LineGraph.Plots.Item(1)
LinePlot.Labels.ShowLabels = True
Set PlotLabels = LinePlot.Labels

'Return if "First row" is set to Auto - should return true
Debug.Print "AutoFirstLabelRow (should be True) = "; PlotLabels.AutoFirstLabelRow

'Return "First row value" - should return 1
Debug.Print "First label row (should be 1) = "; PlotLabels.FirstLabelRow

'Set "First row" to Custom
PlotLabels.AutoFirstLabelRow = False

'Set "First row value" to 5
PlotLabels.FirstLabelRow = 5

'Test "First row value" return after custom setting
Debug.Print "First label row (should be 5) = "; PlotLabels.FirstLabelRow

'Return if "Last row" is set to Auto
Debug.Print "AutoLastLabelRow (should be True) = "; PlotLabels.AutoLastLabelRow

'Return "Last row value" - should return 13
Debug.Print "Last label row (should be 13) = "; PlotLabels.LastLabelRow

'Set "Last row" to Custom
PlotLabels.AutoLastLabelRow = False

'Set "Last row value" to 8
PlotLabels.LastLabelRow = 8

'Return "Last row value" - should return 8
Debug.Print "Last label row (should be 8) = "; PlotLabels.LastLabelRow

'test to see if manually setting AutoLastLabelRow makes a difference
PlotLabels.AutoLastLabelRow = True
Debug.Print "AutoLastLabelRow (should be True) = "; PlotLabels.AutoLastLabelRow

End Sub

 

Updated January 16, 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.