How do I create a polar bar chart in Grapher with a script?

This article contains Grapher sample script showing how to create a polar bar chart and how to change all the methods and properties.


To run this script:

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

 'Open existing windchart.gpj file
 Set existing = GrapherApp.Documents.Open(GrapherApp.Path+"\Samples\windchart.gpj")

 'Display worksheet

 'Save the GPJ data to a DAT file for use in this script
 Set windchartWks1dat = GrapherApp.Documents.Active

 'Close existing graph and data

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

'Creates a graph and assigns it to the variable named "PolarBarChartGraph"
 Set PolarBarChartGraph = Plot1.Shapes.AddPolarBarChartGraph(GrapherApp.Path+"\samples\winddata.dat")

'Set PolarBarChart to the first bar plot on the PolarBarChartGraph graph
 Set PolarBarChart = PolarBarChartGraph.Plots.Item(1)

'AutoPolarBarChart properties

'Returns the angle column
 Debug.Print "Angle column = "; PolarBarChart.aCol

'Sets the angle column to column D
 PolarBarChart.aCol = 1

'Returns the radius column
 Debug.Print "Radius column = "; PolarBarChart.rCol

'Sets the radius column to column C
 PolarBarChart.rCol = 2

'Return the if the angle width is automatically calculated
 Debug.Print "Angle width auto or custom = "; PolarBarChart.AutoAngleWidth

'Sets the angle width to custom
 PolarBarChart.AutoAngleWidth = False

'Returns the angle width
 Debug.Print "Angle width = "; PolarBarChart.AngleWidth

'Sets the angle width to two degrees
 PolarBarChart.AngleWidth = 2

'Returns the bar width
 Debug.Print "Bar width = "; PolarBarChart.barWidth

'Set the bar width to 85 percent
 PolarBarChart.barWidth = 85

'Returns the fill color
 Debug.Print "Fill color = "; PolarBarChart.Fill.foreColor

'Sets the fill color to blue
 PolarBarChart.Fill.foreColor = grfColorBlue

'Returns the label font face
 Debug.Print "Label font = "; PolarBarChart.Labels.Font.face

'Do not display labels
 PolarBarChart.Labels.ShowLabels = False

'Return the bar line style
 Debug.Print "Line style = ";

'Set the line color to green
 PolarBarChart.line.foreColor = grfColorGreen

'Determines if a multivariate polar bar chart is stacked
 Debug.Print "Stacked (stacked/adjacent) = "; PolarBarChart.Stacked

'Sets the stacking to adjacent
 PolarBarChart.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


Please sign in to leave a comment.