"A picture is worth a thousand words," and your graphs can be so rich that they require a thousand words to describe. This session covers the basics of how graphs can be created, updated and output using Visual FoxPro and MSGraph
Why use graphs? Graphs provide a better portrayal of information. The old saw that "a picture worth a thousand words" can be true - far richer information can be conveyed with a single graph that paragraphs of data. In some cases, a single column of data can be better expressed in words - you should have to use a thousand words to describe a picture! Use graphs to show trends, patterns, relationships, multiple layers of information and how they correspond.
The chart above illustrates that MSGraph is capable of far more than simple line and pie charts. It is possible to produce sophisticated charts - those with two-axes, of two different types - bar & line. In addition, it is possible to manually add notations, text boxes and arrows. Your imagination is the only limit. Experiment with the MSGraph interface directly to see the kinds of effects which can be created.
To create the simplest graphs, or to get started on a more sophisticated chart, the Wizard is a good place to start. You don't need to work through the Wizard interface each time, however. The graph Wizard may be invoked through code:
DO (_GENGRAPH) WITH <parm1>[,<parm2>] ...[,<parm9>]
* parm1 - "AUTOGRAPH" &&required
* parm2 - chart type (number)
* parm3 - chart subtype (number)
* parm4 - title (if not empty)
* parm5 - series by row (.T.), by column (.F.)
* parm6 - has legend (.T.)
* parm7 - use autoformat (.F.)
* parm8 - name of output DBF for graph
* parm9 - don't show graph with MODIFY GENERAL (.f.)
The object model of MSGraph is not clear in the documentation which is supplied with Visual FoxPro. However, it is a bonus that VFP 5.0 ships with the help file VBA_GRP.HLP, which accurately documents many of the properties and methods of the graph object. What's missing from the help file are the constants declarations, included on your disks as MSGRAPH5.H
You can examine the internal structure of the MSGraph object, as well as many other OLE controls and servers, using tools often called "OLE Snoopers." A simple one is available from Microsoft on their MSDD and Win32 SDK, as well as on their web site:
ftp://ftp.microsoft.com/developr/MSDN/UnSup-ed/ole2view.exe
Ken Lassesen had an excellent article in the October 1995 issue of the Microsoft Developer's Library, " Mapping the MSGraph Object," where he charts out the entire MSGraph object. Thanks to Ken and Microsoft for permission to reproduce that map here!
Attached are my notes on some of the properties in the MSGraph object which I've explored and tested. There's much more left to go, but I hope these notes (and the object map above) will give you a good start. Please let me know what discoveries you make. Happy hacking!
Creator - returns a (to me) meaningless number, probably some internal OLE
tag.
Parent - points to parent object
Application - points to MSGraph
ColorIndex Range 1 to 56 - points to internal color palette, displayed in many
places as a 7 x 8 grid. Other options include -4105, xlAutomatic, which allows
MSGraph to select the appropriate color. Those colors can be customized through
the interface, but I haven't found access programmatically.
- Contained objects
Chart
- Methods
Quit - watch out! Closes VFP!
SaveAsOldFileFormat([Major],[Minor]) OLE Error "Unknown name"
ChartWizardDisplay?
Creator returns numeric 12973….0000 ?
HasLinks - does not appear to work? OLE Error "Unknown name"
Parent - reference to VFP
Visible - logical
Property Name - returns "Microsoft Visual FoxPro" for OLEBoundControl
and "Microsoft Graph" for OLEBoundControl.Object
Application - pointer to MSGraph
Background - Numeric,
Bold - Logical
Color - RGB Value
FontStyle - text, "Bold," "Bold Italic," etc.
Italic - logical
Name - fontname, "Arial"
OutlineFont - unsure - does this say whether font is outline-able, or allow
an outline effect?
Shadow - logical, creates a shadow effect on font
Size - font point size
Strikethrough - logical
Subscript - logical
Superscript - logical
Underline - logical
Application - pointer to MSGraph
Color - RGB Value
ColorIndex - see ColorIndex comments
Creator - see Creator, above
LineStyle - solid, dashed, or varied shades of grey
Weight - line thickness
Application - pointer to MSGraph
Color - RGB Value
ColorIndex
Creator - see Creator, above
InvertIfNegative - logical
Parent - see above
Pattern - a built-in set of diagonal and hashed patterns
PatternColor - RGB Value
PatternColorIndex - see ColorIndex comments
This one is not a true object, but rather an internal object which is inadvertently exposed. Avoid it.
Application - pointer to MSGraph
Delete()
Border - points to a Border Object, above
Creator - see Creator, above
Name
Parent - see above
Application - pointer to MSGraph
Delete()
Border - points to a Border Object, above
Creator - see Creator, above
Name
Parent - see above
Application - pointer to MSGraph
Delete()
Border - points to a Border Object, above
Creator - see Creator, above
Name
Parent - see above
Application - pointer to MSGraph
Delete()
Border - points to a Border Object, above
Creator - see Creator, above
Name
Parent - see above
* MSGraph5.H
* FoxPro header for MSGraph manipulation
* Generated 13-Sept-96 by OLE2View
#DEFINE xl3DArea -4098
DEFINE xl3DBar -4099
#DEFINE xl3DColumn -4100
#DEFINE xl3DLine -4101
#DEFINE xl3DPie -4102
#DEFINE xl3DSurface -4103
#DEFINE xlArea 1
#DEFINE xlAutomatic -4105
#DEFINE xlBar 2
#DEFINE xlBoth 1
#DEFINE xlBottom -4107
#DEFINE xlBuiltIn 0
#DEFINE xlCap 1
#DEFINE xlCategory 1
#DEFINE xlCenter -4108
#DEFINE xlChecker 9
#DEFINE xlCircle 8
#DEFINE xlColumn 3
#DEFINE xlColumns 2
#DEFINE xlCombination -4111
#DEFINE xlContinuous 1
#DEFINE xlCorner 2
#DEFINE xlCrissCross 16
#DEFINE xlCross 4
#DEFINE xlCustom -4114
#DEFINE xlDash -4115
#DEFINE xlDashDot 4
#DEFINE xlDashDotDot 5
#DEFINE xlDefaultAutoFormat -1
#DEFINE xlDiamond 2
#DEFINE xlDistributed -4117
#DEFINE xlDot -4118
#DEFINE xlDouble -4119
#DEFINE xlDoubleAccounting 5
#DEFINE xlDoughnut -4120
#DEFINE xlDown -4121
#DEFINE xlDownward -4170
#DEFINE xlExponential 5
#DEFINE xlFixedValue 1
#DEFINE xlGray16 17
#DEFINE xlGray25 -4124
#DEFINE xlGray50 -4125
#DEFINE xlGray75 -4126
#DEFINE xlGray8 18
#DEFINE xlGrid 15
#DEFINE xlHairline 1
#DEFINE xlHigh -4127
#DEFINE xlHorizontal -4128
#DEFINE xlInside 2
#DEFINE xlInterpolated 3
#DEFINE xlJustify -4130
#DEFINE xlLeft -4131
#DEFINE xlLightDown 13
#DEFINE xlLightHorizontal 11
#DEFINE xlLightUp 14
#DEFINE xlLightVertical 12
#DEFINE xlLine 4
#DEFINE xlLinear -4132
#DEFINE xlLogarithmic -4133
#DEFINE xlLow -4134
#DEFINE xlMaximized -4137
#DEFINE xlMaximum 2
#DEFINE xlMedium -4138
#DEFINE xlMinimized -4140
#DEFINE xlMinimum 2
#DEFINE xlMinusValues 3
#DEFINE xlMovingAvg 6
#DEFINE xlNextToAxis 4
#DEFINE xlNoCap 2
#DEFINE xlNone -4142
#DEFINE xlNormal -4143
#DEFINE xlNotPlotted 1
#DEFINE xlOpaque 3
#DEFINE xlOutside 3
#DEFINE xlPercent 2
#DEFINE xlPicture -4147
#DEFINE xlPie 5
#DEFINE xlPlus 9
#DEFINE xlPlusValues 2
#DEFINE xlPolynomial 3
#DEFINE xlPower 4
#DEFINE xlPrimary 1
#DEFINE xlRadar -4151
#DEFINE xlRight -4152
#DEFINE xlRows 1
#DEFINE xlScale 3
#DEFINE xlSecondary 2
#DEFINE xlSemiGray75 10
#DEFINE xlSeries 3
#DEFINE xlShowLabel 4
#DEFINE xlShowLabelAndPercent 5
#DEFINE xlShowPercent 3
#DEFINE xlShowValue 2
#DEFINE xlSingle 2
#DEFINE xlSingleAccounting 4
#DEFINE xlSolid 1
#DEFINE xlSquare 1
#DEFINE xlStDev -4155
#DEFINE xlStError 4
#DEFINE xlStack 2
#DEFINE xlStar 5
#DEFINE xlStretch 1
#DEFINE xlThick 4
#DEFINE xlThin 2
#DEFINE xlTop -4160
#DEFINE xlTransparent 2
#DEFINE xlTriangle 3
#DEFINE xlUp -4162
#DEFINE xlUpward -4171
#DEFINE xlValue 2
#DEFINE xlVertical -4166
#DEFINE xlWizardDisplayAlways 1
#DEFINE xlWizardDisplayDefault 0
#DEFINE xlWizardDisplayNever 2
#DEFINE xlX -4168
#DEFINE xlXYScatter -4169
#DEFINE xlY 1
#DEFINE xlZero 2
Microsoft Developer Library, Randy Brown, "Extending the Visual FoxPro Wizards"
Microsoft Developer Library, Ken Lassesen, "Mapping the MSGraph Object"
Microsoft Developer Library, Ken Lassesen, " Using Microsoft OLE Automation Servers to Develop Solutions"
Microsoft Knowledgebase articles - available via CompuServe (GO MSKB) and on the Microsoft web site (http://www.microsoft.com/kb)
Q129533 - "How to Pass Data to Microsoft Graph Programmatically"
Q131029 - "How to Manipulate Embedded Objects in General Fields"
Q135348 - "How to Update a Graph in a Form"
VBA_GRP.HLP: Help file for using Visual Basic for Applications with MSGraph - should be included with VFP 5.0 (not yet confirmed), installed in <Windows Dir>\MSAPPS\Graph5
Tufte, Edward, "Envisioning Information," Graphics Press, 1990
Tufte, Edward, "The Visual Display of Quantitative Information," Graphics Press, 1990