Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / FoxPro / Setup / September 2003

Tip: Looking for answers? Try searching our database.

Problem With Graph Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
R.K.Softwares - 15 Sep 2003 12:22 GMT
I am using Graph Control "_autograph.vcx" but on client machine, it gives
error, Microsoft Graph is not properly installed, run office setup again. My
clients may not be using Microsoft Office, Is there any way around ?
Eric den Doop - 15 Sep 2003 12:38 GMT
Hello, R.K.Softwares!
You wrote  on Mon, 15 Sep 2003 16:52:40 +0530:

RS> I am using Graph Control "_autograph.vcx" but on client machine, it
RS> gives error, Microsoft Graph is not properly installed, run office
RS> setup again. My clients may not be using Microsoft Office, Is there any
RS> way around ?

Although you are permitted to distribute the MSGraph runtime libraries, you
can not create graphs on the fly with the runtime version. You need the
full version of MSGraph to create dynamic graphs. The full version comes
with MS Office, (Word, Excel etc).
I'd rather use ole automation to create a graph in an Excel sheet. If you
upgrade to VFP7 or VFP8, then you can easily access Excel/Msgraph properties
thru IntelliSense.

Here's a sample on how to create a chart in Excel using ole automation:
<vfp_code>
CREATE CURSOR tmp (ccountry C(20), nvalue N(2))
APPEND BLANK
REPLACE ccountry WITH "Netherlands, The", nvalue WITH 10
APPEND BLANK
REPLACE ccountry WITH "Belgium", nvalue WITH 5
APPEND BLANK
REPLACE ccountry WITH "Germany", nvalue WITH 2
loExcel = CREATEOBJECT("Excel.Application")
loWorkBook = loExcel.workbooks.add
loSheet = loWorkbook.worksheets(1)
SELECT tmp
GO TOP
SCAN
  loSheet.range("A" + TRANSFORM(RECNO())).numberformat = "@"
  loSheet.range("A" + TRANSFORM(RECNO())).formular1c1 = tmp.ccountry
  loSheet.range("B" + TRANSFORM(RECNO())).formular1c1 =
TRANSFORM(tmp.nvalue)
ENDSCAN
loRange = loSheet.range("A1:B" + TRANSFORM(RECCOUNT()))
loChart = loExcel.charts.add
loChart.charttype = -4102
loSheet.activate
loChart.SetSourceData(loRange, 2)
loChart.location(2, loSheet.name)
loSheet.ChartObjects(1).chart.hastitle = .T.
loSheet.ChartObjects(1).chart.charttitle.text = "Test graph"
loExcel.visible = .T.
</vfp_code>

If you do not want to use MSGraph because of the runtime limit, of the full
MSOffice is not available on the computer, then you can
use the MSChart active x control. This control isn't as fancy as MSGraph,
but you do can create some basic graphics with this control. An other
alternative is to search the web for third party graph controls/libraries.
Here's an MSChart sample:
<vfp_code>
PUBLIC chartdemo
chartdemo=CREATEOBJECT('chartdemo')
chartdemo.SHOW

DEFINE CLASS chartdemo AS FORM

TOP = 0
LEFT = 0
HEIGHT = 250
WIDTH = 360
DOCREATE = .T.
CAPTION = "MSChart Control"
NAME = "Form1"

ADD OBJECT olecontrol1 AS OLECONTROL WITH ;
TOP = 24, ;
LEFT = 42, ;
HEIGHT = 181, ;
WIDTH = 277, ;
VISIBLE = .F., ;
NAME = "Olecontrol1", ;
OLECLASS="MSChart20Lib.MSChart.2"

ADD OBJECT command1 AS COMMANDBUTTON WITH ;
TOP = 216, ;
LEFT = 24, ;
HEIGHT = 24, ;
WIDTH = 121, ;
CAPTION = "\<Show Chart", ;
NAME = "Command1"

ADD OBJECT command2 AS COMMANDBUTTON WITH ;
TOP = 216, ;
LEFT = 216, ;
HEIGHT = 24, ;
WIDTH = 120, ;
CAPTION = "E\<xit", ;
NAME = "Command2"

PROCEDURE command1.CLICK
WITH THISFORM.olecontrol1
! Display a 3d chart with 8 columns and 8 rows of data.
.ChartType = 0 && VtChChartType3dBar
! Set the number of columns to 8
.COLUMNCOUNT = 8
! Set the number of rows to 8
.RowCount = 8

! Populate the DataGrid Object.
FOR lnCol = 1 TO 8
FOR lnRow = 1 TO 8
.COLUMN = lnCol
.ROW = lnRow
.DATA = lnRow * 10
NEXT ROW
NEXT COLUMN
! Use the chart as the backdrop of the legend.
.ShowLegend = .T.
! Select Chart Part 1
.SelectPart(1,1,1,1,1) && VtChPartTypePlot, index1, index2, index3, index4)
!   Copy the chart to the clipboard in Windows Metafile format.
.EditCopy
! Select Chart Part 1
.SelectPart(1,1,1,1,1) && VtChPartTypeLegend, index1, index2, index3,
index4)
! Paste the Windows Metafile graphic from the clipboard into the chart
.EditPaste
! Set the chart object visible
.VISIBLE=.T.
! Refresh the chart object
.REFRESH
ENDWITH
THISFORM.REFRESH
ENDPROC

PROCEDURE command2.CLICK
WITH THISFORM
.RELEASE
ENDWITH
ENDPROC

ENDDEFINE
</vfp_code>

Good luck.
Signature

Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.