How can I create and edit a line graph map in MapViewer via automation?

This article contains a sample script for creating a line graph map and editing the methods and properties of the line graph map.

To run this script:

  1. Copy the script below, or click here to download the BAS file: Create_LineGraph_Map.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\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.


' Create_LineGraph_Map.BAS
' Copyright (C) Golden Software Inc. 1992-2015
' This sample demonstrates how to create a line graph map and change the properties

Sub Main

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

'Makes the application main window visible
mvApp.Visible = True

'Assigns the location of the samples folder to the variable "InPath"
InPath$ = mvApp.ApplicationFolder + "samples\"

'Creates a map document object, and assigns it to the variable named "Plot"
Set Plot = mvApp.Documents.Add(DocType:=mvDocPlot)

'Creates a line graph map object and assigns it to the variable named "LineGraphMap"
Set LineGraphMap = Plot.CreateLineGraphMap(InPath$ + "co2010.gsb", InPath$ + "co2010.dat", "", _
"SecondaryIDField=2, Attribute1Field=1", 1, 7)

'Sets the baseline for a line graph map
LineGraphMap.AddBaseline = True

'Sets the state of the break line for a line graph map
LineGraphMap.AddBreakLine = True

'Sets a graph's base height to 0.5

'Sets the properties for the baseline
LineGraphMap.Baseline.color = mvColorOrange
LineGraphMap.Baseline.Width = 0.05
LineGraphMap.Baseline.Style = "Dash Dot"

'Sets the properties for the break line
LineGraphMap.BreakLine.color = mvColorNeonRed
LineGraphMap.BreakLine.Width = 0.02
LineGraphMap.BreakLine.Style = "Dash Dot Dot"

'Sets the data break value for a line graph map to 40000

'Sets the state of descending order graphing

'Sets the state of using global data from the worksheet
LineGraphMap.GlobalData = True

'Sets the fill properties for the line graph
LineGraphMap.GraphFill.ForeColor = mvColorBlue
LineGraphMap.GraphFill.BackColor = mvColorGreen
LineGraphMap.GraphFill.Pattern="Forward Slash"
LineGraphMap.GraphFill.Transparent = True

'Sets the graph height to 0.75

'Sets the graph line properties
LineGraphMap.GraphLine.Width = 0.01

'Sets the graph position centroid offset type to User Defined

'Sets the graph position X offset.

'Sets the Graph position Y offset.

'Sets the state of horizontal graph

'Sets the PID column of the worksheet.

'Sets the Profile fill properties

'Sets the Profile line properties
LineGraphMap.ProfileLine.color = mvColorBlue
LineGraphMap.ProfileLine.Width = 0.02

'Returns the state of the User Limits checkbox
Debug.Print "UserLimits = "+LineGraphMap.UserLimits

'Returns the User Limits max value
Debug.Print "UserLimitMaxVal = "+LineGraphMap.UserLimitMaxVal

'Returns the User Limits min value
Debug.Print "UserLimitMinVal = "+LineGraphMap.UserLimitMinVal

'Creates a legend for the map
Set Legend = LineGraphMap.CreateLegend(-2,6)

'Adds the LineGraphMap information in Layer #1 to legend
LineGraphMap.AddLayerToLegend("Layer #1")

End Sub


Updated August 20, 2018

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


Please sign in to leave a comment.