Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Graphs
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Re: Graphs
Miscellaneous
Thread ID:
00051529
Message ID:
00051627
Views:
43
>>>I'm curious as to how many of you are handling graphs in VFP. I've played around with the Graph Wizard, but it seems to me that I would not want a user to have to go this route to create a graph. I would need to be able to define a view, run it and then simply send off some parameters to create the graph then either display it to screen or print it much like we can do with the REPORT command.
>>>
>>>Thanks,
>>>Steve Despres
>>Hi Steve.
>>
>>I generally have a "seed" graph that I use and modify using APPEND GENERAL DATA and give it the info to modify the graph. Then, if you put the graph in a form, you can manupulate any of its properties. The best part is that MSGraph comes with VFP and is free. Let me know if you would like some code samples...I will dig them up. Also, there are several good articles in the knowledge base on how to do this if you are interested.
>>
>>Best Regards.
>>
>>Marcia
>
>Marcia,
>
>Thanks and I was wondering if MSGraph came with VFP or whether it came with Office, both of which I have so I couldn't seem to tell. I'd appreciate any examples that you care to send and I'll have to head out to the knowledge base to take a look at things out there. I played a little with it but I didn't spend much time with it and didn't get what I wanted. I know I've got to put more time into it. Any and all assistance would be appreciated.
>
>Thank you,
>Steve Despres
>sdespres@crosslink.net
Hi Steve.
Here is some of the code that I used to manipulate the graphs in my reports. My seed graph is a three dimensional horizonal bar graph.
The procedure MakeGRaph assumes that the cursor GraphDat exists. This graph is an age analysis of Roof Areas by Facility. The cursor is the result of the following SQL statement:

SELECT Facility.Fac_Short, ;
SUM(IIF(nyears=1,ROOF->c_squ/1000,0)) AS n Age1,;
SUM(IIF(nyears=2,ROOF->c_squ/1000,0)) AS n Age2,;
SUM(IIF(nyears=3,ROOF->c_squ/1000,0)) AS nAge3,;
SUM(IIF(nyears=4,ROOF->c_squ/1000,0)) AS nAge4 ;
FROM facility, roof ;
WHERE ROOF->cl_code=FACILITY->cl_code ;
AND ROOF->regn_cd=FACILITY->regn_cd ;
AND ROOF->fac_cd=FACILITY->fac_cd ;
AND FACILITY->cl_code=pClient ;
AND Facility.Regn_Cd == pRegion;
GROUP BY FACILITY->regn_cd, FACILITY->fac_cd ;
ORDER BY FACILITY->regn_cd, FACILITY->Fac_Short ASC ;
INTO Cursor GraphDat
USE


PROCEDURE MakeGraph
SELECT GraphBmp
ZAP
APPEND BLANK
REPLACE GraphBmp WITH Graph.Graph
SELECT GraphDat
cGraphString = ""
* Build tab-delimited string of field names:
FOR iCounter = 1 TO FCOUNT("GraphDat")
IF UPPER(ALLTRIM(FIELD(iCounter))) <> "REGN_CD" THEN
cGraphString = cGraphString + FIELDS(iCounter) ;
+ IIF(iCounter < FCOUNT("GraphDat"),CHR(9),chr(13))
ENDIF
ENDFOR

* Concatenate the data, converting numeric fields to character:
SCAN
FOR iCounter = 1 TO FCOUNT("GraphDat")
IF UPPER(ALLTRIM(FIELD(iCounter))) <> "REGN_CD" THEN
cGraphString = cGraphString + IIF(TYPE(Fields(iCounter))='C',;
EVALUATE(FIELDS(iCounter)) ;
,str(EVALUATE(FIELDS(iCounter)),16,2);
);
+ IIF(iCounter < FCOUNT("GraphDat"),CHR(9),CHR(13))
ENDIF
ENDFOR
ENDSCAN
SELECT GraphBmp
APPEND GENERAL GraphBmp DATA cGraphString
RETURN

And here is the code that pulls the graph into a form to manipulate properties such as color, axis titles, etc.

FrmDummy=CREATEOBJECT("Form")
FrmDummy.ADDOBJECT("OleGraph","OleBoundControl")
WITH FrmDummy.OleGraph
.Height = 900
.Width = 600
.ControlSource = "GraphBmp.GraphBmp"
.ChartArea.Border.Color = RGB(0,0,128)
.ChartArea.Interior.Color = RGB(255,255,128)
.HasLegend = .T.
.HasTitle = .F.
.Legend.LegendEntries(4).Legendkey.Interior.Color = RGB(255,0,0) && Red
.Legend.LegendEntries(3).Legendkey.Interior.Color = RGB(255,255,0) && Yellow
.Legend.LegendEntries(2).Legendkey.Interior.Color = RGB(0,255,255) && Cyan
.Legend.LegendEntries(1).Legendkey.Interior.Color = RGB(0,0,128) && Blue
.HasLegend = .F.
.Axes(2).HasTitle = .T.
.Axes(2).AxisTitle.Caption = "Square Footage in Thousands"
.Axes(2).AxisTitle.Font.Size = 10
.Axes(2).TickLabels.Font.Size = 10
.Axes(1).TickLabels.Font.Size = 10
ENDWITH
RELEASE FrmDummy

There is a help file called VBA_GRP.hlp that will give you the properties and methods belonging to the graph. I don't remember off-hand where to download this file. Someone else here may know.

By the way, MSGraph comes with Both Office and VFP.

Good Luck.

Marcia
Previous
Reply
Map
View

Click here to load this message in the networking platform