MS Graph Again
VFP is a very powerful tool. You can do almost everything related with business application, but NOT Graphing. VFP developers got to use third party tool to generate and print graph. One of the most common graphing tool for VFP developers is MS Graph. MS Graph is come with MS Excel. Therefore, make sure MS Excel is installed in order to use MS Graph.
You may notice that, questions about using MS Graph are posted to forum again, again and again. Therefore, I decided to blog abit about it.
There are couple of way to use MS Graph. AFAIK, there are :
- Automate Microsoft Excel via OLE Automation
- Use VFP AutoGraph FFC or VFP GenGraph wizard
- Use General field to link data to MS Graph.
Automate Microsoft Excel via OLE Automation
Pros:
Since we are automating MS Excel, then we can do anything MS Excel offer, instead of just graphing. In other words, we can not only generate graph, but also can use MS Excel features such as formatting, table drawing, formula calculation and etc. It makes our graph report looks more attractive and modern.
Also, the generated graph could be saved on disk for future use.
Cons:
It is slower and required more resources since not only MS Graph is initiated but also MSExcel.Application.
Use VFP AutoGraph FFC or VFP GenGraph wizard
Pros:
This is the easiest way to generate graph. We only required to follow the wizard steps by steps with informative guideness on wizard form and press "Finish". Graph will be generated. No coding is required.
Cons:
Refresh MS Graph content is not straight forward for VFP developers. For more info about it, pls check my previous blog.
The generated graph couldn't be printed. We can't bind it to VFP report field control.
Use General field to link data to MS Graph
Pros:
We still have 100% of control to our graph via MS Graph automation provided without need to automate whole MSExcel.Application. We can allow user to preview it on form, and also print using VFP native report system. Alot more information available on web, help files and VFP sample code.
Cons:
I can't think of any for now.
This is a simple sample code file I created using General field appraoch. In fact, I use this appraoch alot for graphing and it works very well till now.
For preview and print graph in VFP report
- Create a report.
- Place Picture/ActiveX Bound Control on report's details band.
- Select Field option in Picture From option box.
- Key in "csrGraph.myGraph" in field textbox.
- Resize the control to size as need.
- Preview report.
BTW, remember to get VBAGR10.chm help file. It would save us alot of time.
Updated: Article Graphing in VFP by Ted Roche. Thank you.
2 Comments:
I presented a session on blogging at the 2003 DevCon. You can find the paper at http://www.tedroche.com/Present/2003/ADX304.html
Thank you Ted Roche for sharing. :)
Post a Comment
<< Home