Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need an example of creating a graph
Message
From
20/01/1999 09:38:17
 
 
To
19/01/1999 22:06:53
Dennis Schuette
Customized Business Services, Llc
Yuma, Arizona, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00177874
Message ID:
00177980
Views:
35
>Does anyone have a simple example of creating a graph programatically in VFP 5. Thank you.

Hi Denis.

If you are going to be creating graphs on the fly in your runtime, you can't use the graph wizard. But if you have a 'seed' graph you can use APPEND GENERAL DATA to manipulate the seed graph in the following manner:
 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")
     cGraphString = cGraphString  + FIELDS(iCounter) ; 
                  + IIF(iCounter < FCOUNT("GraphDat"),CHR(9),chr(13)) 
 ENDFOR 

 * Concatenate the data, converting numeric fields to character: 
 SCAN 
    FOR iCounter = 1 TO FCOUNT("GraphDat")
        cGraphString = cGraphString  + IIF(TYPE(Fields(iCounter))='C',; 
                       EVALUATE(FIELDS(iCounter)) ; 
                       ,str(EVALUATE(FIELDS(iCounter)),16,2); 
                            ); 
                     + IIF(iCounter < FCOUNT("GraphDat"),CHR(9),CHR(13)) 
    ENDFOR 
 ENDSCAN 
 SELECT GraphBmp 
 APPEND GENERAL GraphBmp  DATA cGraphString 
In the above example, GraphDat contains the seed graph and GraphDat contains the data sheet for the graph. To manipulate the graph's properties, you need to do it in a form like so:
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(1).Legendkey.Interior.Color = RGB(255,0,0)	 && Red
     .Legend.LegendEntries(2).Legendkey.Interior.Color = RGB(255,0,128)  && Pink      
     .Legend.LegendEntries(3).Legendkey.Interior.Color = RGB(255,255,0)  && Yellow
     .Legend.LegendEntries(4).Legendkey.Interior.Color = RGB(0,255,255)  && Cyan
     .Legend.LegendEntries(5).Legendkey.Interior.Color = RGB(0,0,128)    && Blue
     .HasLegend = .F.
     .Axes(1).TickLabels.Font.Size = 10
     .Axes(2).HasTitle = .T.
     .Axes(2).AxisTitle.Caption = "Thousands of Dollars"
     .Axes(2).AxisTitle.Font.Size = 10
     .Axes(2).TickLabels.Font.Size = 10
ENDWITH
RELEASE FrmDummy
Hope this helps get you started.

Marcia
Previous
Reply
Map
View

Click here to load this message in the networking platform