Example Code Shows How to Refresh a GraphLast reviewed: October 17, 1996Article ID: Q140860 |
The information in this article applies to:
SUMMARYPrevious versions of FoxPro could call procedures (refreshgrph, updategrph) that were built into the Graph Wizard to redraw a chart to reflect changes in data. While this functionality was never officially supported, the information was made available to customers and many developers used it. This article gives example code for the equivalent functionality using Visual FoxPro and the new Graph Wizard. Of course, it is only intended as an example, your tables and so will be different.
MORE INFORMATION
Assumptions
Using the CodeYou could place this code in the Click event of a button marked "Refresh Chart."
Code Sample** Select the work area and turn off the console SELECT PHONZ SET CONSOLE OFF SELECT email, avg_time, FROM PHONZ INTO CURSOR SPCRES ** Now the data is in the cursor SPCRES. The table with the graph in it ** needs to have the current record deleted. The following code ** adds the updated chart in a new record. The operation seems to ** confuse the olebound control, so you should lock the screen, so ** you won't see it. Then set the controlsource of the olebound control ** to null for the duration. ** ** Note that the wizard does not just modify the chart that you are ** on, it appends a new record with a new chart. If you don't want ** your table to grow every time that you do this, you must delete ** the current record. ** ** The spcgrph table must be packed after deletion, so it must ** be opened exclusivly. Because the Wizard leaves spcgrph opened ** non-exclusivly, it needs to be closed and re-opened. select spcgrph delete pack use thisform.lockscreen = .T. thisform.oleboundcontrol1.controlsource = "" ** Load the New chart
SELECT SPCRES DO (_GENGRAPH) WITH "AUTOGRAPH", 4, 1, "Test1",,,,"spcgrph",.T.** after using this wizard, the graph table (spcgrph) is open, but it ** is not open exclusively. Note that if you had more than one chart ** in the table, you would have to do some fancy shuffling at this point ** to make sure that you were on the right record. (the one that you want ** to show in the form. select spcgrph use use spcgrph.dbf in 0 exclusive ** Close the cursor and go back where you came from
SELECT SPCRES USE SELECT PHONZ thisform.oleboundcontrol1.controlsource = "spcgrph.olegraph" thisform.lockscreen = .F.** Refresh the Form THISFORM.REFRESH THISFORM.OLEBOUNDCONTROL1.REFRESH ******************* End Of Code ******************************
REFERENCESFor more information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q140291 TITLE : How to call graph wizard & create a chart programmatically |
Additional reference words: 5.00 3.00 3.00b
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |