This article contains a sample script for creating a graph, returning and setting the rows used for plotting labels.
To run this script:
- Click here to download the BAS file: rowlabels.bas.
- Click Automation | Scripts | Run, select the BAS file from your downloads directory, and click Open.
- Copy the script below.
- Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
- Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
- Press Ctrl+V to paste it into the Script Manager.
- 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