Microsoft KB Archive/101597

From BetaArchive Wiki

Using UPDATEGRPH in GENGRAPH.APP

ID: Q101597



The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b
  • Microsoft FoxPro for Macintosh, version 2.5b




SUMMARY

The GraphWizard is a FoxPro application named GENGRAPH.APP. The UPDATEGRPH procedure updates a graph that was created and saved with the GraphWizard using the data in the currently selected DBF/cursor. The updated graph can then be displayed using the SHOWGRPH procedure.


MORE INFORMATION

In version 2.5, the correct syntax for calling UPDATEGRPH is:

DO UPDATEGRPH IN GENGRAPH.APP WITH <expC1>, <expN1> ; [, <expN2>[, <expC2>]]

The clauses that are used with the UPDATEGRPH procedure in version 2.5 are <expC1> and <expN1> and two optional clauses: <expN2> and <expC2>.

  • <expC1> is the name of the table containing the previously saved graph. The GraphWizard names this table QRYGRAPH.DBF by default.
  • <expN1> is the record number containing the graph to be displayed.
  • <expN2> is a mode number (0 or 1) that determines how the data in the current work area will be inserted in the saved graph. The default mode is 1.
  • <expC2> is the graph title.

In versions 2.5a and 2.5b, the correct syntax for calling UPDATEGRPH is:

DO UPDATEGRPH IN GENGRAPH.APP WITH <expC1>, <expN1>[, <expN2> ; [, <expC2>[, <array>, <expC3>]]]

The clauses that are used with the UPDATEGRPH procedure in versions 2.5a and 2.5b are <expC1> and <expN1> and four optional clauses: <expN2>, <expC2>, <array>, and <expC3>.

  • <expC1> is the name of the table containing the previously saved graph. The GraphWizard names this table QRYGRAPH.DBF by default.
  • <expN1> is the record number containing the graph to be displayed.
  • <expN2> is a mode number (0, 1, or 2) that determines how the data in the current work area will be inserted in the saved graph. The default mode is 1.
  • <expC2> is the graph title.
  • <array> is an array of <expC> containing the names of the fields in the order in which they are to appear in the graph data rectangle. This clause is used in mode 2 only.
  • <expC3> is the name of the field to use for x-axis (horizontal axis) labels (the clause may be blank). This clause is used in mode 2 only.

When mode = 0, UPDATEGRPH converts the currently selected DBF/cursor into the format that Microsoft Graph requires and inserts the data in the previously saved graph (the new data replaces the previous data). The graph data will match the DBF/table structure. For example, if a MODIFY GENERAL window is double-clicked to bring up MS Graph itself, a spreadsheet- like array of data will appear. If UPDATEGRPH is called with mode = 0, this spreadsheet mirrors the structure of the DBF/cursor that is open in the current work area.

The first field in the DBF/cursor is used for the x-axis labels, and the other fields are stored as numeric values in the appropriate cells of the spreadsheet. It is your responsibility to ensure that the DBF/cursor fields are in the proper order and that they contain data that can be graphed. Compared with mode 1 and mode 2, mode 0 provides an intermediate level of flexibility, but makes you do more work. For example:

   DO UPDATEGRPH IN GENGRAPH.APP WITH ;
     "c:\foxprow\qrygraph.dbf",4,0,"Graph Title" 

When mode = 1 (the default if no mode is specified), UPDATEGRPH updates the previously saved graph with data from the currently selected DBF/table. In this mode, UPDATEGRPH and REFRESHGRPH do essentially the same thing. The previously saved field names, order of data, x-axis field, and graph title are used to format the new data in the saved graph.

If you attempt to update a graph with data from a DBF/cursor that does not contain all the fields found in the DBF/cursor originally used for the graph, the message "Cannot update that graph with this data" will appear. Although the new DBF/cursor can contain the fields in a different order or contain additional fields, all the original fields must be present in order to update the graph. For example:

   DO UPDATEGRPH IN GENGRAPH.APP WITH "c:\foxprow\qrygraph.dbf",4 

In versions 2.5a and 2.5b, when mode = 2, you must supply <array> and <expC3> to UPDATEGRPH, which will use them to format the data found in the currently selected DBF/cursor. Mode 2 provides the most flexibility but requires the most work to set up. You would use this mode if the DBF/cursor fields were not already ordered in the sequence that the graph requires, or if only a few of the fields found in the DBF/cursor are to be included in the graph.

In versions 2.5a and 2.5b, the syntax is as follows:

DIMENSION g_flist[4]

g_flist[1] = "field1" && name of first data field
g_flist[2] = "field2" && name of next data field
g_flist[3] = "field3" && ... and so forth
g_flist[4] = "field4"
g_xaxis = "field5" && name of field whose values go on x-axis

DO UPDATEGRPH IN GENGRAPH.APP WITH; "c:\foxprow\qrygraph.dbf",4,2,"Graph title",; g_flist, g_xaxis

For example, suppose you used the GraphWizard to create a line chart, then customized the chart from within MS Graph (changing fonts, repositioning the legend, modifying colors, and so forth). Furthermore, suppose that the graph contains sales data from a field named "Sales". The x-axis labels are month names from a "Months" field. You save the customized graph in a DBF/table called QRYGRAPH.DBF. QRYGRAPH.DBF already has other seven other graphs in it--the new graph is saved in record number 8. Later, you want to reuse the same carefully customized graph to display data from completely different fields, perhaps "Expenses" and "Years" instead of "Sales" and "Months". You can use the UPDATEGRPH procedure to make such changes to the original graph. For example:

  • The DBF with the expenses and years data is in the current work area:
   DIMENSION g_flist[1]
   g_flist[1] = "Expenses"
   g_xaxis = "Years"
   DO updategrph IN gengraph.app WITH "qrygraph.dbf", 8, 2, ;
     "Expenses by Year", g_flist, g_xaxis 

This command updates the stored graph in record 8 of QRYGRAPH.DBF. The new graph title is "Expenses by Year". The first column of data -- the data shown in the MS Graph spreadsheet if a graph was double-clicked -- comes from the DBF/cursor field "Expenses". The x-axis labels are drawn from the values stored in the DBF/cursor field named "Years".

NOTE: In FoxPro for Macintosh only, executing UPDATEGRPH changes the font of window "screen" to Geneva, 10. Additional query words: FoxMac FoxWin 2.50 msgraph

Keywords          : kbcode FxinteropSpread 
Version           : 2.50 2.50a 2.50b | 2.50b
Platform          : MACINTOSH WINDOWS 
Issue type        : 

Last Reviewed: August 20, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.