Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making a graph
Message
From
02/07/2001 08:56:08
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
30/06/2001 10:32:12
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
Miscellaneous
Thread ID:
00525325
Message ID:
00525828
Views:
25
>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
Ç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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform