Follow

How to I create adjacent bar charts in Grapher via automation?

This article contains Grapher sample script that shows how to create a bar chart graph, add a second adjacent bar chart, and change some properties.

 

To run this script:

  1. Copy the script below, or click here to download the BAS file: Bar Chart-Adjacent.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.
     

*********

Sub Main
'This script shows how to create two bar charts and make them adjacent to each other

'Declares GrapherApp as an object
 Dim GrapherApp As Object

'Creates an instance of the Grapher Application
'object and assigns it to the variable named "GrapherApp"
 Set GrapherApp = CreateObject("Grapher.Application")

'Makes Grapher Visible
 GrapherApp.Visible = True

'Declares Plot as an object
 Dim Plot As Object

'Creates a plot document in Grapher and assigns
'it to the variable named "Plot"
 Set Plot = GrapherApp.Documents.Add(grfPlotDoc)

'Declares Shapes as Object
 Dim Shapes As Object

'Assigns the AutoShapes collection to the
'variable named "Shapes"
 Set Shapes = Plot.Shapes

'Declares BarChart as Object
 Dim BarChartGraph As Object

'Create a bar chart and graph
 Set BarChartGraph = Shapes.AddBarChartGraph(GrapherApp.Path+"\samples\bar chart orientations.dat",,,)

'Add a second bar chart to the graph
 BarChartGraph.AddBarChart(GrapherApp.Path+"\samples\bar chart orientations.dat",,3,)

'Assign the first bar chart to the object name BarChart1
 Set BarChart1 = BarChartGraph.Plots.Item(1)

'Set the bars to use only rows 1-10
 BarChart1.AutoLastRow = False
 BarChart1.LastRow = 10

'Change the first bar chart to blue fill
 BarChart1.Fill.foreColor(grfColorBlue)

'Make the bar charts adjacent
 BarChart1.Stacked=False

End Sub

 

Updated September 22, 2016

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.