Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Graphs too big to distribute
Message
De
29/04/1999 11:12:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/04/1999 10:53:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00213468
Message ID:
00213492
Vues:
31
>I have an application that has about 40 graphs stored in a general field of a table. The application then passes the current data to the graph for display. Simple application. Problem, the table is 80 mg. Is there a better way of doing this. Maybe creating the graph on the fly rather than storing the graph in a general field. Any advise would be helpful.
>
>TIA
>Robert
Robert,
MSGraph could be managed by OLEAut. so create them on the fly. If it's MSGraph8 then run excel and record macro to create the same graph type. Get macro code and do some furnishing to fit it to VFP syntax. Here is a little sample that does all on the fly :
*** set the LOCALEID to English
nlLocaleId=sys(3004)		&& Save local id
=sys(3006,1033)				&& We will be sending instructions in English

* Part of xlChartType constants
#DEFINE xl3DArea 					-4098
#DEFINE xl3DColumn					-4100
#DEFINE xl3DLine					-4101
#DEFINE xl3DPie						-4102
#DEFINE xlArea						1
#DEFINE xlBubble3DEffect			87
#DEFINE xlLine						4
#DEFINE xlPie						5
#DEFINE xlRadar						-4151
#DEFINE xlSurface					83

#DEFINE TAB CHR(9)
#DEFINE CRLF CHR(13)+CHR(10)


CREATE cursor test (degree i, sine n(8,4) NULL, cosine n(8,4))
FOR ix = 1 to 90
  INSERT into test ;
    values ;
    (ix,cos(ix)*ix,sin(ix)*ix)
ENDFOR
45
SCAN next 30     && Nullify 30 degrees
  REPLACE sine with .null.       && Nullify some values to see effect
ENDSCAN


WAIT window nowait "Filling cell values..."
MCGDATA = ""
nCols = fcount()
FOR ix = 1 to nCols
  MCGDATA = MCGDATA + iif(empty(MCGDATA),"",TAB)+field(ix)
ENDFOR
MCGDATA = MCGDATA + CRLF
SCAN
  FOR ix = 1 to nCols
    MCGDATA = MCGDATA + iif(ix=1,"",TAB)+nvl(str(evaluate(field(ix))),"")
  ENDFOR
  MCGDATA = MCGDATA + CRLF
ENDSCAN
* Data prepare *

CREATE cursor testgen (genfld1 g)
APPEND blank
APPEND general genfld1 class "msgraph" data MCGDATA
CREATE report testgraph from testgen
MESSAGEBOX("Pls add an OLEBoundControl to report and size big enough. Field name is [genfld1]")
MODI report testgraph
***
* Now we have Graph object in gen field. (Graph8)
* Play with it

oForm = createobject("Form")
WITH oForm
  .height = 400
  .width = 600
  .show
  .closable = .f.
  .addobject("myGraph","OleBoundControl")
  .addobject("myQuit1","myQuit")
  .addobject("myChanger1","myDataChanger")
  .addobject("myChanger2","myTypeChanger")
  .addobject("myReport1","myReport")
  WITH .myGraph
    .height = oForm.height - 20
    .width = oForm.width
    .left = 0
    .top = 0
    .ControlSource = "testgen.Genfld1"

    .hasdatatable = .t.
    .DataTable.HasBorderOutline = .T.
    WITH .DataTable.font
      .name = "Arial"
      .size = 8
    ENDWITH

    WAIT window nowait "Plotting..."
    .hastitle = .t.
    .haslegend = .t.
    .ChartTitle.caption = "This is chart title"
    .ChartType=xl3DArea
    .object.application.plotby = 2
    #DEFINE xlCategory		1
    #DEFINE xlValue			2
    #DEFINE xlSeriesAxis	3
    WITH .Axes(xlCategory)
      .hastitle = .t.
      WITH .AxisTitle
        .Caption = "This is category title"
        .Font.Name = "Arial"
        .Font.Size = 10
        .Font.Bold = .t.
      ENDWITH
    ENDWITH
    WITH .Axes(xlSeriesAxis)
      .hastitle = .T.
      WITH .AxisTitle
        .Caption = "This is SeriesAxis title"
        .Font.Size = 8
        .Font.Bold = .f.
        .Orientation = 90 && Show 90 degrees rotated
      ENDWITH
    ENDWITH
    WITH .Axes(xlValue)
      .hastitle = .T.
      WITH .AxisTitle
        .Caption = "This is Value title"
        .Font.Size = 10
        .Font.Bold = .f.
        .Orientation = 90 && Show 90 degrees rotated - clockwise
      ENDWITH
    ENDWITH
    WAIT clear
    .ChartArea.copy()
    .visible=.T.
  ENDWITH
  .myQuit1.visible = .t.
  .myReport1.left = .myChanger2.left+.myChanger2.width + 5
  .myReport1.visible = .t.
  .myChanger1.visible = .t.
  .myChanger2.visible = .t.
ENDWITH
**** Set the LocaleId to the previous value
=sys(3006,val(nlLocaleId))

READ events

DEFINE class myquit as commandbutton
  Left=1
  Top=0
  AutoSize = .T.
  Caption="Close"
  PROCEDURE click
  Release all
  Clear events
ENDPROC
ENDDEFINE

DEFINE class myDataChanger as commandbutton
  Left=150
  Top=0
  AutoSize = .T.
  Caption="Change some data"
  PROCEDURE click
  WAIT window nowait "Changing cell values..."
  WITH thisform.myGraph.object.application.datasheet
    SELECT test
    SCAN
      IF isnull(sine)
        .Cells(recno()+1,2).Value = sin(recno())*recno()
      ENDIF
    ENDSCAN
  ENDWITH
  SELECT testgen
  thisform.myGraph.doverb(-6)
  WAIT clear
ENDPROC
ENDDEFINE

DEFINE class myTypeChanger as commandbutton
  Left=300
  Top=0
  AutoSize = .T.
  Caption="Change Chart Type"
  PROCEDURE click
  thisform.myGraph.ChartType = xlBubble3DEffect
  thisform.myGraph.doverb(-6)
ENDPROC
ENDDEFINE

DEFINE class myreport as commandbutton
  Left=1
  Top=0
  AutoSize = .T.
  Caption="Report"
  PROCEDURE click
  * warning !!! - Testgraph prepared manually containing gen field and sized
  MESSAGEBOX("If you changed graphtype click once to update."+chr(13)+"This is a quirk of MSGraph.")
  REPORT form testgraph preview
ENDPROC
ENDDEFINE
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform