Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create a graph on a form ?
Message
 
À
04/12/1997 08:07:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00063607
Message ID:
00064013
Vues:
66
>>>>Does anyone know how to display data as a diagramm and include this diagramm on a form ?
>>>>ActiveX ??? Microsoft Graph ??? Native Visual Foxpro 5.0 tools ??
>>>>Thank you in advance.
>>>>Igor Gelin.
>>>
>>>You can do this with MS Graph, personally i like to do this with a OCX called Graphics Server developed for Pinnacle Publishing.
>>>
>>>http://www.pinpub.com/
>>>
>>>Mauricio Atanache G.
>>>dsmauricio@HotMail.Com
>>
>>Thank you!
>>May you explain me how I can do it with MS Graph ?
>>Sincerely, Igor
>Hi Igor.
>
>Here is some sample code of how I did it with MS Graph. Hope this helps.
>
>First, I got the data for my graph like so:
>
>
>* Calculate graph data for all facilities
>
>SELECT Facility.Fac_Short, ;
> SUM(IIF(c_years=1,ROOF->c_squ/1000,0)) AS Age1,;
> SUM(IIF(c_years=2,ROOF->c_squ/1000,0)) AS Age2,;
> SUM(IIF(c_years=3,ROOF->c_squ/1000,0)) AS Age3,;
> SUM(IIF(c_years=4,ROOF->c_squ/1000,0)) AS Age4 ;
> 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
>
>
>Next, I use a seed graph and the following code to udata the data in the graph:
>
>
>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
>
>
>Finally, this is how I manipulate the graph to look thye way I want it to:
>
>
>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
>
>
>Marcia

Thanks a lot!!!
I am allset now.
Igor Gelin
Igor Gelin
Database Developer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform