How To Call the Graph Wizard & Create a Chart Programmatically

Last reviewed: March 11, 1997
Article ID: Q140291
3.00 3.00b 5.00 |3.00b
WINDOWS         MACINTOSH
kbinterop kbgraphic kbhowto

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0
  • Microsoft Visual FoxPro for Macintosh, version 3.0b

SUMMARY

You can create a Chart in Microsoft Graph from the data in the currently selected work area by calling the Graph Wizard programmatically.

MORE INFORMATION

To create a Chart programmatically, use this syntax:

   SELECT <table to be graphed>
   DO (_GENGRAPH) WITH <parm1> [,<parm2] [,<parm3]...[,<parm9>].

NOTE: If DO command listed above causes the error "File does not exist," an alternative command is:

    DO HOME() + 'wizards\wzgraph.app' WITH <parm1> [,<parm2] ... [,<parm9>]

IMPORTANT: this code will not work in an executable run outside of Visual FoxPro. The Graph Wizard will always take its data from the currently selected table.

The Graph Wizard application (Wzgraph.app) accepts these parameters:

   parm1 - "AUTOGRAPH" (required)
   parm2 - chart type (numeric)
   parm3 - chart subtype (numeric)
   parm4 - title (character)
   parm5 - series by row / column (logical)
   parm6 - has legend (logical)
   parm7 - use autoformat (logical)
   parm8 - output DBF (character)
   parm9 - don't display graph with MODIFY GENERAL (logical)

How the Parameters Interact with Each Other

Parm1 - "AUTOGRAPH"

If a character string other than "AUTOGRAPH" is specified, Visual FoxPro will present either Step 1 (if no table is open) or Step 2 of the interactive Graph Wizard. If you use "AUTOGRAPH" and no table is open, the Graph Wizard returns an error, if a table is open, the resulting behavior depends on the value of parm8.

Parm8 - output DBF

If Parm8 is omitted or empty (for example, "   "), you will be prompted for
an output file name. If you supply the name of an output file, it must be an existing .dbf file that contains a General field. If the file does not exist, the Graph Wizard returns this error:

   The table you selected is already in use.

WARNING: If the file exists, but does not contain a General field, the file is deleted and replaced with a new table of that name containing a single record with a single General field that contains the Graph object. Each call to (_GENGRAPH) with the same file name in parm8 adds a new record to the table and places the generated graph in the General field.

Parm7 - use autoformat

The value of this parameter influences how the numbers passed to parm2 and parm3 are interpreted.

Parm2 - chart type and parm3 - chart subtype

If parm7 is true (.T.), parm2 will be 1-15 corresponding to the options in the Gallery list that is displayed when you click AutoFormat on the Format menu in MSGraph. Parm3 will be the number of the selected format displayed for the specific Gallery selected.

If parm7 is false (.F.), parm2 will be 1-14 corresponding to the chart types that are displayed when you click Chart Type on the Format menu in MSGraph. The first 1-8 are the 2-D charts (counted from left to right and top to bottom), 9-14 are the 3-D chart types. Parm3 will be one of the Subtypes that are displayed when you click the Options button in the Chart Type window. Valid numbers depend on which Chart Type is specified.

Parm4 - title.

This is the title that will appear on the chart. If left empty or omitted, the chart will have no title. This is the same as setting the ChartTitle property of the chart.

Parm5 - series by row /column

This is the equivalent to clicking either Series in Rows or Series in Columns on the Data menu in MSGraph. True (.T.) indicates Series in Rows, and false (.F.) indicates Series in Columns. These settings are explained in the Microsoft Graph Help file.

Parm6 - has legend

If this is true (.T.), the chart displays a legend. This is the same as setting the HasLegend property of the chart.

Parm9 - don't display graph with MODIFY GENERAL

If this is false (.F.) the General field is displayed in a window as though the MODIFY GENERAL command had been issued.


Additional reference words: 5.00 vFoxMac 3.00b 3.00 VFoxWin
KBCategory: kbinterop kbgraphic kbhowto
KBSubcategory: FxinteropOle
Keywords : FxinteropOle kbgraphic kbhowto kbinterop
Version : 3.00 3.00b 5.00 |3.00b
Platform : MACINTOSH WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.