Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Making a graph
Message
De
26/09/2001 09:43:04
 
 
À
02/07/2001 08:56:08
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Divers
Thread ID:
00525325
Message ID:
00560922
Vues:
28
I posted a message yesterday but I think it was lost because of UT problems, so I'll ask again.
In VFP I want to bring up an existing Word document that contains a MS Chart and then be able to manipulate the chart from VFP.
i.e.
loWord = createobject("word.application")
loWord.Documents.open("C:\junk.doc") && junk contains a MS Chart
Then get an object reference to the chart
Then be able to manipulate the datagrid, etc. of the chart through the object reference.

How do I do this?
How do I get the object reference?

This ought to be easy but I can't figure it out.
Thanks



>>Thanks Cetin, but I dont know anything about it.
>>I wonder if you tell me where can I get it and How to use.
>
>Andrews,
>For MSGraph and Excel samples are posted here. For a fast one I suggest to use MSChart2.0 control. Here is sample code using it (you can get full help by clicking on activex after you drop one on to form). First random data generated for Corvette, Ferrari sales from 1998 to 2000 quarterly, xtabbed then graphed :
>
>
ColorsMax=3
>Dimension colors[3]
>ColorS[1] ='Red'
>ColorS[2] ='Silver'
>ColorS[3] ='Black'
>Rand(-1)
>Create cursor comparesales (nyear i, qtr i, car c(10), color c(10))
>For years = 1998 to 2000
>  For iQtr = 1 to 4
>    For Sales = 1 to 10
>      Insert into comparesales ;
>        values (years, iQtr, ;
>        iif(int(rand()*1000)%2=0,'Corvette','Ferrari'), ;
>        colors[int(rand()*ColorsMax)%5+1])
>    Endfor
>  Endfor
>Endfor
>
>* Our xtabber
>Select distinct car from comparesales into array arrCars order by car
>Asort(Colors)
>Dimension Sales[2+alen(arrCars)*alen(colors)]  && 2 for year and qtr
>Dimension arrStruc[alen(Sales),4]
>arrStruc = 0
>arrStruc[1,1] = 'Year'
>arrStruc[1,2] = 'I'
>arrStruc[1,3] = 4
>arrStruc[2,1] = 'Qtr'
>arrStruc[2,2] = 'I'
>arrStruc[2,3] = 4
>
>For ix=1 to alen(arrCars)
>  For jx = 1 to alen(colors)
>    lnCurFieldNum = (ix-1)*alen(colors)+jx+2
>    arrStruc[lnCurFieldNum,1] = padr(arrCars[ix],5,'_')+padr(colors[jx],5,'_')
>    arrStruc[lnCurFieldNum,2] = 'I'
>    arrStruc[lnCurFieldNum,3] = 4
>  Endfor
>Endfor
>Create cursor crsXTab from array arrStruc
>
>For years = 1998 to 2000
>  For iQtr = 1 to 4
>    Sales = 0
>    m.year = years
>    m.qtr  =  iQtr
>    Select car,color,cnt(*) as amount ;
>      from comparesales ;
>      group by 1,2 ;
>      where nyear = years and qtr = iQtr ;
>      into cursor crsCounts
>    Scan
>      Store amount to ('m.'+padr(trim(car),5,'_')+padr(trim(color),5,'_'))
>    Endscan
>    Insert into crsXTab from memvar
>  Endfor
>Endfor
>Select crsXTab
>**** Data is prepared and ready in crsXTab - Graph
>
>oForm = createobject('myForm')
>With oForm
>  With .MSChart
>&& Set Chart parameters using methods.
>    .rowCount = reccount()
>    .columnCount = fcount()-2
>    Scan
>      .Row = recno()
>      For ix=3 to fcount()
>        .Column = ix-2
>        .Data = eval(field(ix))
>      Endfor
>    Endscan
>
>    With .DataGrid
>      rowLabelCount = 2
>      columnLabelCount = 2
>      rowCount = reccount()
>      ColumnCount = fcount()-2
>      .SetSize(rowLabelCount, columnLabelCount, rowCount, ColumnCount )
>      * Assign labels
>      For iColors = 1 to columncount
>        .ColumnLabel(iColors, 1) = Colors[(iColors-1)%alen(colors)+1]
>      Endfor
>      For iCars=1 to alen(arrCars)
>        .ColumnLabel((iCars-1)*alen(colors)+1, 2) = arrCars[iCars]
>      Endfor
>      For iQtr = 1 to rowCount
>        .RowLabel(iQtr, 1) = (iQtr-1)%4+1
>      Endfor
>      For years=1998 to 2000
>        .RowLabel((years-1998)*4+1, 2) = transform(years)
>      Endfor
>    Endwith
>    .ShowLegend = .T.
>  Endwith
>  .Show()
>Endwith
>Read events
>
>Define CLASS myForm AS form
>  Top = 0
>  Left = 0
>  Height = 574
>  Width = 793
>  DoCreate = .T.
>  Caption = "Form1"
>  Name = "Form1"
>
>  Add OBJECT MSChart AS olecontrol WITH ;
>    Top = 2, ;
>    Left = 2, ;
>    Height = 550, ;
>    Width = 778, ;
>    Name = "MsChart",;
>    OleClass='MSChart20Lib.MSchart.2'
>  Procedure queryunload
>  Clear events
>Endproc
>Enddefine
Cetin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform