JavaScript Editor js editor     Web development 



Main Page

File: ...\Samples\Solution\Reports\Ordgraph.scx

This sample illustrates generating and printing graphs on the fly. Visual FoxPro makes it possible for you to add graphs to forms as either OleControls or OleBoundControls. The latter representing a graph, which is bound to data using a General field.

If you intend to use the Visual FoxPro report writer to print graphs, you need to use General fields to store the graphs. The easiest way to create a new graph in a General field is to use the APPEND GENERAL command, for example:

В Copy Code
APPEND GENERAL graphfield CLASS "msgraph"

The example above will create a graph in a General field, however, it will not contain your data. The DATA clause actually passes data to the graph.

The following code loops through records already containing data and constructs a string to pass to the graph with APPEND GENERAL .... DATA:

В Copy Code
SCAN NEXT m.totrecs
   m.cData = ""+TAB+m.f2+TAB+m.f3+TAB+m.f4+CRLF+;
      EVAL(fields(1))+ TAB + ;
      ALLTRIM(STR(EVAL(field(2))))+ TAB +;
      ALLTRIM(STR(EVAL(field(3))))+ TAB + ;
      ALLTRIM(STR(EVAL(field(4))))
   m.cDetails = ;

f2+"-" +ALLTRIM(STR(EVAL(FIELD(2)))) ;
      + CRLF + f3+"-" +ALLTRIM(STR(EVAL(FIELD(3)))) ;
      + CRLF + f4+" - "+ALLTRIM(STR(EVAL(FIELD(4)))) +CRLF
   INSERT INTO prodsales ;
VALUES(SalesData.prod_name,tmpgrph.graph,m.cDetails)
   APPEND GENERAL prodsales.sales DATA m.cData
ENDSCAN

Once you have a table or cursor containing a General field with your graphs, you can then print it to a Visual FoxPro report using the REPORT FORM command. You cannot include an ActiveX control in a report.

See Also



JavaScript Editor js editor     Web development