Microsoft Graph and Visual FoxPro
|
within DISTRIBUTED Visual FoxPro Applications See Microsoft's Knowledge Base Article entitled INFO: Limitations of Run-Time MS Graph |
SUMMARY
|
WORKAROUNDS
|
MORE INFORMATION
|
within DISTRIBUTED Visual FoxPro Applications See Microsoft's Knowledge Base Article entitled INFO: Limitations of Run-Time MS Graph |
|
Alternative Graphing Controls to MSGRAPH
|
|
Flipper Graphics Control by ProWorks Chart FX by Software FX Graphic Server by Pinnacle Publishing
|
|
Alternative Graphing Controls to MSGRAPH
|
Notes about Microsoft Graph and Visual FoxPro...
Selected Knowledge Base Articles about Microsoft Graph and Visual FoxPro... (Updated!)
Microsoft's FTP (Download) Software Library...
Frustrations about Microsoft Graph and Visual FoxPro...
Tips and Tricks...
Where to find OLE Automation and Technical Information about Microsoft Graph (MSGRAPH)
Setting the Minimum/Maximum value for the Value (Y) Axis
Setting the Axis Title (and other attributes) of the Category (X) Axis or Value (Y) Axis
Use Excel to Gernerate a Visual Basic for Applications (VBA) Macro to get you started
Use ChartWizard() to set basic Graph Attributes
How to turn off Minor (or Major) Ticks Marks
Setting the Minimum value for the Category (X) Axis
Use ScreenLock to reduce flicker
View/Modify Setting and Data with a Right-Click on the Graph
How do you want Microsoft Graph to handle missing data? Use DisplayBlanksAs to specify.
What are the available Graph Types and SubTypes?
Specifying Graph Types and SubTypes
Setting the Maximum value for the Category (X) Axis
Using MS Graph with MS Visual FoxPro, Article by Michael Darrin Chaney
Future Tips and Tricks...
One of the biggest problems that I've had with Microsoft Graph is the lack of definitive information about controlling the graph programatically. There is very little information about OLE Automation of Microsoft Graph and even less concerning its use with Visual FoxPro. As a result I have spent a lot of time search for help. I've looked for books, online articles, in help files, etc. I have found very little helpful definitive information.
The on book that I have found particularly useful is...
This book contains two chapters that will be helpful in working with Charts in Visual FoxPro. "Creating Charts", Chapter 13, and "Controlling Charts", Chapter 14, provides a lot of information and examples about programming your charts. The "Table of Intrinsic Constants", Appendix C, is valuable for creating the #DEFINEs that you will be using.
This book is a reference for Excel and its Graphing/Charting software, so not everything applies nor is done in exactly the same way in Visual FoxPro and Microsoft Graph. (Excel does not use MSGraph, it has it's own graphing software.) It does supply examples and information that will help you understand how things work.
The other books that I have found with information about Using MS GRAPH with Visual FoxPro are...Both of these are good books, but don't buy them just for the section on MS GRAPH. Miriam has a little more information than Tamar does about MS GRAPH.
There should be a Help file on you system called, VBA_GRP.HLP. Mine is
located in...
C:\Program Files\Common Files\Microsoft Shared\Msgraph5\VBA_GRP.HLPYours may be someplace else. Use the find utility to find it. This Help file is also a good place to get information about Visual Basic for Applications and MSGraph.
This help file briefly describes the Methods and Properties related to Microsoft Graph. There are short examples contained.
If you're a Compuserve member, go to the VFOX forum and download a file named MSGRAPH5.H. This file is a header file that includes the Intrinsic Constants for MSGRAPH Version 5. (These are also listed in Jeff Webb's book, Using Excel VBA, in Appendix C, "Table of Intrinsic Constants". [Buy It])[NOW Available!]
If you're not a member of Compuserve, you might want to consider joining. The VFOX Forum is a great forum.
I have a web page Microsoft Graph (MSGRAPH) Version 5: Properties, Methods and Intrinsic Constants that is an edited copy of what was reported by the OLE/COM Object Viewer that is found in Visual C/C++. This report shows you all of the Properties and Methods that are in MSGRAPH/5. The report also contains a list of all the Intrinsic Contstants that you will need. I have another web page that is just a list of the Microsoft Graph (MSGRAPH) Version 5: Intrinsic Constants for Visual FoxPro. This page is a sorted list of the FoxPro #DEFINEs that you need.
There is an article on the Microsoft Knowledge Base that lists these contants also. The article is INFO: Microsoft Graph Constants. Please note: There is at least one value that is wrong in this article. The article has xl3DArea defined as -409. It should be defined as -4098.
On Compuserve, in the VFOX forum there is a file called FRMGRAPH.ZIP. This file is a sample of how to do OLE Automation of MS GRAPH. It reads a database, creates a cursor and passes that information to MSGRAPH. The program also sets some parameters related to how the graph is to be displayed.
There is an article on the Microsoft Knowledge Base, PRB: Olegraph.scx Sample Fails if Graph 8 Is Installed, that discribes a problem with the provided OLE Automation of MS Graph example that comes with Visual FoxPro. This application is a simple example, but is worth looking at. It is found in ..\samples\solution\ole.
There are limitations related to what capabilities are available to applications that distribute MSGRAPH. See the following Article.
There are a couple of Microsoft articles that talk about MSGRAPH and OLE Automation.
The Microsoft Knowledge Base contains some articles about MSGRAPH and it's use in products like Access, Excel, etc...
Microsoft Knowledge Base usage
The Microsoft Knowledge Base Articles related to Visual FoxPro and MSGRAPH are found at Richard Hendricks' Visual FoxPro Tips under the List of Selected Microsoft Knowledge Base Articles... Section
Microsoft has an FTP (Download) Site that contains a lot of patches, examples and free utilities.
Take a look at the Index.txt file for the /Softlib/MSLFILES subdirectory. Use this file to find the files that you need. The files are stored in /Softlib/MSLFILES. There are lots of files here. Look around...
The following link, takes you to the Microsoft's Software
Library Files FTP Directory (/Softlib/MSLFILES). You will be presented with a
FTP list of files. You can click on the file(s) that you want or add the
filename to the URL
("ftp://ftp.microsoft.com/Softlib/MSLFILES/") in the
"Location:" text box.
PlotBy = xlColumns option in ChartWizard() to work.Platform: Windows/95
Products: Visual FoxPro/5 and Microsoft Graph/5
Prepared: 07/14/1998 .. 07/23/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The places that I have found information about OLE Automation of Microsoft Graph (MSGRAPH) are...
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/26/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
To set the Minimum and Maximum Value for the Value (Y) Axis, you must first set the MinimumScaleIsAuto and MaximumScaleIsAuto to .F.
#DEFINE xlValue 2
WITH this.oleGraph.Axes(xlValue) && Y Axis
.MaximumScaleIsAuto = .F.
.MinimumScaleIsAuto = .F.
.MaximumScale = 50
.MinimumScale = -50
ENDWITH
Note: this will not work on the Category (X) Axis. I have tried and tried and tried... It does not work. (This is one of my frustrations!)
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/25/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
To set the Axis Title and other Axis Title attributes you must first set the HasTitle to .T.
#DEFINE xlCategory 1
#DEFINE xlValue 2
#DEFINE xlVertical -4166
WITH this.oleGraph.Axes(xlValue) && Y Axis
.HasTitle = .T.
.AxisTitle.Caption = "Title for Y Axis" && .AxisTitle.Text is also OK
.AxisTitle.Orientation = xlVertical
.AxisTitle.Font.Italic = .T.
.AxisTitle.Font.Bold = .T.
.AxisTitle.Font.Size = 8
ENDWITH
WITH this.oleGraph.Axes(xlCategory) && X Axis
.HasTitle = .T.
.AxisTitle.Caption = "Title for X Axis" && .AxisTitle.Text is also OK
.AxisTitle.Font.Italic = .T.
.AxisTitle.Font.Bold = .T.
.AxisTitle.Font.Size = 8
ENDWITH
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Recorded: 07/25/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
You can use Microsoft Excel (and maybe other Microsoft Apps) to generate Visual Basic for Applications (VBA) code to get you started with your graph.
To do this...
Start Excel, prepare the data you want to graph, Select "Tools" | "Record Macro" | "Record New Macro" | "Options" | "Language" set to "Visual Basic" | "OK"
Set up the Chart the way that you want it. Stop the recording and use the generated macro to give you a start.
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Recorded: 07/25/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Microsoft Graph Supports ChartWizard(). This allows you to set quite a few attributes about your graph in one call.
chart.ChartWizard( Source, Gallery, Format, PlotBy, CategoryLabels,
SeriesLabels, HasLegend, Title, CategoryTitle,
ValueTitle, ExtraTitle )
Source - where does the data come from, normally left blank and uses
the current cusor or database
Gallery - type of graph, xlXYScatter, etc
Format - subtype of graph
PlotBy - is the data by rows or by columns, xlRows or xlColumns
CategoryLabels - Are there labels in the data?
If so, what row or column?
SeriesLabels - Are there labels in the data?
If so, what row or column?
HasLegend - Does the graph have a Legend? .T./.F.
Title - Title of the Chart
CategoryTitle - Category (X) Axis Title
ValueTitle - Value (Y) Axis Title
ExtraTitle - Extra Title, I haven't gotten this to work.
#DEFINE xlXYScatter -4169
#DEFINE xlRows 1
this.oleGraph.ChartWizard( , xlXYScatter, 1, xlRows, 1, 1, .T.,;
"Title of my chart", "X Axis Title",;
"Y Axis Title", "" )
Note: I have not been able to get the xlColumns option for PlotBy to work. Only xlRows, seems to work.
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Recorded: 07/25/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Do not set MinorUnit to 0. This will cause an error. Set MinorUnit to 1 and MinorTickMark to xlNone.
#DEFINE xlCategory 1
#DEFINE xlValue 2
#DEFINE xlNone -4142
#DEFINE xlCross 4
WITH this.oleGraph.Axes(xlValue) && works for xlCategory also
.MinorUnit = 1 && works for MajorUnit too
.MinorTickMark = xlNone && works for MajorTickMark too
ENDWITH
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/26/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
You CAN NOT use the approach of setting the MinimumScale and MaximumScale values for the Category (X) Axis as you do with the Value (Y) Axis. See Setting the Minimum/Maximum value for the Value (Y) Axis
You can set the Minimum Value of the Category (X) Axis, if it is the value that you want to cross the Value (Y) Axis.
If lets say you want the minimum value on the Category (X) Axis to be 50, then you would use the following code...
#DEFINE xlCategory 1
#DEFINE xlCustom -4114
WITH this.oleGraph.Axes(xlCategory) && X axis
.Crosses = xlCustom
.CrossesAt = 50
ENDWITH
Frustration! I have been unable to specify the Minimum/Maximum values (with the MinimumScale and MaximumScale) for the Category (X) Axis. You are supposed to be able to, for XYScatter Graphs, but I can't. If you know how to do this, please eMail me at 70302.144@compuserve.com
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/26/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
During window Resizing and other situation, you will want to set ScreenLock to .T. This will reduce the amount of flickering and unwanted sets that the user will see. After the operation is complete, set ScreenLock to .F.
thisform.ScreenLock = .T. <<resizing or other redrawing code>> thisform.ScreenLock = .F.
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/26/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
During development, you can Right-Click on the graph to see and set graph attributes and the data behind the graph.
Right-Click on the Graph. You will be presented with a Popup Menu that contains Edit and Open. Click on Open. A Window titled, "Microsoft Graph - Graph in" with be added to your application. The window has a tool bar and a menu bar. From the menu bar you can...
There are lots of other things that you can do in this mode. Take some time to look around. It will help you debug your graphs.
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/27/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
You can specify how you want Microsoft Graph to handle blank or missing data. You do this through the DisplayBlanksAs
#DEFINE xlNotPlotted 1 && Default #DEFINE xlZero 2 #DEFINE xlInterpolated 3 this.oleGraph.DisplayBlanksAs = xlZero
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/27/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The available Graph types are...
The SubType for the Graph vary depending on what Graph you selected. In Microsoft Excel or in Visual FoxPro under AutoFormat, you can see the possible SubTypes. The number on the sample is the number of the SubType.
Visual FoxPro: Right-Click on the Graph. From the Popup Menu select Open. On the Window titled, "Microsoft Graph - Graph in" from the menu bar select Format | AutoFormat
Microsoft Excel: Create some sample data, highlight it and click on the ChartWizard Icon or Insert | Chart | On this Sheet or As New Sheet. Walk through the Wizard and view the SubTypes.
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/27/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
There are at least two ways to specify the Graph Type (Scatter, Line, Pie, etc) and Sub Graph Type.
ChartWizard(): the 2nd and 3rd argument of the ChartWizard() call is the Graph Type and Sub Type, respectively. ChartWizard() calles them Gallery and Format.
#DEFINE xlXYScatter -4169
#DEFINE xlRows 1
this.oleGraph.ChartWizard( ,xlXYScatter, 1, xlRows, 1, 1, .T.,;
"Chart Title", "X Axis Caption",;
"Y Axis Caption", "" )
AutoFormat(): the 1st argument, Gallery, is the Graph Type and the 2nd argument, Format, is the Sub Type.
#DEFINE xl3DPie -4102 this.oleGraph.AutoFormat( xl3DPie, 1 )
See What are the available Graph Types and SubTypes?
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/28/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
You CAN NOT use the approach of setting the MinimumScale and MaximumScale values for the Category (X) Axis as you do with the Value (Y) Axis. See Setting the Minimum/Maximum value for the Value (Y) Axis
You can set the Maximum Value of the Category (X) Axis, with the the TickLabelSpacing attribute.
The TickMarkSpacing attribute can be used to specify the Tick Marks.
If lets say you want the maximum value on the Category (X) Axis to be 50 and the tick marks to be by 10s, then you would use the following code...
#DEFINE xlCategory 1
WITH this.oleGraph.Axes(xlCategory) && X axis
.TickLabelSpacing = 50
.TickMarkSpacing = 10
ENDWITH
Also see, Setting the Minimum value for the Category (X) Axis
Frustration! I have been unable to specify the Minimum/Maximum values (with the MinimumScale and MaximumScale) for the Category (X) Axis. You are supposed to be able to, for XYScatter Graphs, but I can't. If you know how to do this, please eMail me at 70302.144@compuserve.com
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Prepared: 07/31/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Platform: Windows/95
Products: Microsoft Graph/5 and Visual FoxPro/5
Article by: Michael Darrin Chaney [eMail]
Tip Prepared : 05/10/1999
Tip Prepared by: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
|
|
|
Copyright © 1998 by Richard Hendricks All Rights Reserved. Feel free to use these tips and tricks in your applications and feel free to share copies and the information to your friends and colleagues. You may not re-sell the original or the source code. If you redistribute it you must include the disclaimer and all original copyright notices. Do not remove the contributors names, copyright notices and disclaimer. Give credit where credit is due. The information given here is believed to be correct, but no legal liability can be accepted for its use. No warranty express or implied, is given as to the use of the information or source code. Use at your own risk. The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications. Microsoft Corporation holds the rights and copyrights for FoxPro, Visual FoxPro, Visual Basic, Excel, Access and Microsoft Graph |