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. Copy the script below, or download the attached BAS file: rowlabels.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.


The HTML Clipboard
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 April 14, 2017

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


Please sign in to leave a comment.