1 Son düzenleyen, mrduyar (08.02.2007 11:11:12)

Konu: rapora grafik ekleme

Selamlar;

Rapora grafiği nasıl ekleyebilirim?

Bilmediğin Neyse Yanıldığındır.

2

Re: rapora grafik ekleme

eski kodlarimin arasinda buldugum bir cozum

mygraph.dbf adinda bir dosyan var ( olegraph G ) asagidki kodla grafige yansiyacak datalar olusturuluyor ve form uzerinde OLEBOUND CONTROL uzerinde gosteriliyor


Visual Fox Pro
If ! Used("mygraph")

    Use data03\MYGRAPH In 0 Exclusive
    Pack
Endif
 
#Define TABULATE Chr(9)
#Define CRLF Chr(13)+Chr(10)
 
 
 
Select ilce,count(ilce) as sayisi;       
FROM okul2;
WHERE ttarih between thisform.txttar1.Value AND thisform.txttar2.Value ; 
    group BY ilce;
    INTO Cursor MYCURSOR
 
*Wait window "Datalar oluşturuluyor..." nowait
MCGDATA = ''
nCols = Fcount()
For ix = 1 To nCols
    MCGDATA = MCGDATA + TABULATE+Field(ix)
Endfor
MCGDATA = MCGDATA + CRLF
Scan
    MCGDATA = MCGDATA+'' &&trans(recno())
    For ix = 1 To nCols
        MCGDATA = MCGDATA + TABULATE+Trans(Evaluate(Field(ix)))
    Endfor
    MCGDATA = MCGDATA + CRLF
Endscan
 
Select MYGRAPH
Append General MYGRAPH.Olegraf Data MCGDATA &&NEWDATA
Thisform.Refresh
Thisform.oleboundcontrol1.Refresh


yazdir buton kodu asagidaki gibi , raporada OLEBOUND CONTROL koyuyorsun controlsource a mygraph.olegraf yaziyorsun ve raporda goruntulenmesini sagliyorsun

Visual Fox Pro
Repo Form rapor\grafik To Printer Prompt Prev Window repwindow Noconsole

3

Re: rapora grafik ekleme

teş.
bana lazım olan aslında grafik.frx in içine nasıl oleyi koyduğun.
formda zaten grafik görünüyor.

bu arada vfp8 kullaıyorum bunun için.

Bilmediğin Neyse Yanıldığındır.

4

Re: rapora grafik ekleme

tamamdır yaptım.

Bilmediğin Neyse Yanıldığındır.

5

Re: rapora grafik ekleme

Soykan Merhaba,
Yanlış anlamadıysam, Aşağıdaki örneğinde Kadıköy 15 Üsküdar 10 vs. gibi ilçeler ve bu ilçede oturanların sayısını grafik için hazırlayıp MCGDATA değişkenine text olarak koydun. Daha sonra
Append General MYGRAPH.Olegraf Data MCGDATA
satırıyla Mygraph kütğündeki Olegraph General field'ine bunu yazdın. Rapora koyduğun olebound'a control source olarak da general field'i veriyorsun. Bunun CHART datası olduğunu, general field'in chart içerdiğini nerede belirtiyorsun, chart'ı nasıl oluşturuyorsun ? Benzer bir şey yazdım, MCGDATA ile chartı oluşturacak datayı oluşturuyorum ama APPE GENERAL ile bir şey eklenmiyor, neyi eksik yapıyorum. (Çok soru sordum galiba smile)



soykanozcelik yazdı:

eski kodlarimin arasinda buldugum bir cozum

mygraph.dbf adinda bir dosyan var ( olegraph G ) asagidki kodla grafige yansiyacak datalar olusturuluyor ve form uzerinde OLEBOUND CONTROL uzerinde gosteriliyor


Visual Fox Pro
If ! Used("mygraph")

    Use data03\MYGRAPH In 0 Exclusive
    Pack
Endif
 
#Define TABULATE Chr(9)
#Define CRLF Chr(13)+Chr(10)
 
 
 
Select ilce,count(ilce) as sayisi;       
FROM okul2;
WHERE ttarih between thisform.txttar1.Value AND thisform.txttar2.Value ; 
    group BY ilce;
    INTO Cursor MYCURSOR
 
*Wait window "Datalar oluşturuluyor..." nowait
MCGDATA = ''
nCols = Fcount()
For ix = 1 To nCols
    MCGDATA = MCGDATA + TABULATE+Field(ix)
Endfor
MCGDATA = MCGDATA + CRLF
Scan
    MCGDATA = MCGDATA+'' &&trans(recno())
    For ix = 1 To nCols
        MCGDATA = MCGDATA + TABULATE+Trans(Evaluate(Field(ix)))
    Endfor
    MCGDATA = MCGDATA + CRLF
Endscan
 
Select MYGRAPH
Append General MYGRAPH.Olegraf Data MCGDATA &&NEWDATA
Thisform.Refresh
Thisform.oleboundcontrol1.Refresh


yazdir buton kodu asagidaki gibi , raporada OLEBOUND CONTROL koyuyorsun controlsource a mygraph.olegraf yaziyorsun ve raporda goruntulenmesini sagliyorsun

Visual Fox Pro
Repo Form rapor\grafik To Printer Prompt Prev Window repwindow Noconsole

6

Re: rapora grafik ekleme

class "Msgraph.chart"

(Ama MSGraph'i tavsiye etmem).

7

Re: rapora grafik ekleme

Soykan Hocam, Çetin Hocam,

Hallettim,
APPEND GENERAL komutunun sonuna CLASS "MSGraph.Chart" ibaresini ekleyince oldu. Bir de "ExcelChart" olabildiğini biliyorum. Başka türler de var mı acaba ve tavsiyeniz hangisi ?

Bir de oluşturulan bu grafiğin renk, scale, label vb. özelliklerine nasıl müdahale edilebiliyor fikri olan var mı?

8

Re: rapora grafik ekleme

MsChart bence cok daha iyi. Ornek gonderiyorum ama tek satırlık mesajlar bile gitmiyor nedense foruma, deniyorum.

9

Re: rapora grafik ekleme

Dün ben de mesaj gönderemekte çok zorlandım, bugün de sistem çok ağır.

Göndereceğiniz örnekte rapor içinden kullanımına yönelik bilgi olursa çok sevinirim.
Şimdiden teşekürler.

10

Re: rapora grafik ekleme

Visual Fox Pro
*** 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
#include xlconstants.h
#Define TABULATE Chr(9)
Wait Window Nowait "Filling cell values..."
 
Select country,Cnt(*) As 'Count' From customer Group By country Into Cursor crsGraph
lcTempFile = Sys(2015)+'.tmp'
Copy To (lcTempFile) Type Csv
MCGDATA = Chrtran(Filetostr(lcTempFile),',',TABULATE)
Erase (lcTempFile)
 
Create Cursor testgen (graphtest g)
Append Blank
Wait Window Nowait "Plotting..."
Append General graphtest Class MSGraph.Chart Data MCGDATA
 
Public oForm
oForm = Createobject("myForm")
With oForm
  .Show
  .AddObject("myGraph","OleBoundControl")
  With .myGraph
    .Height = oForm.Height - 10
    .Width = oForm.Width - 10
    .Left = 5
    .Top = 5
    .ControlSource = "testgen.graphtest"
    .Object.Application.plotby = xlColumns
    .HasLegend = .F. && No legend
    .hastitle = .T.
    With .ChartTitle
      .Caption = 'Customer Count by Country'
      .Shadow = .T.
      .Font.Size = 14
      .Font.Color = 0x00FFFF
      .Interior.Color = 0xFF0000
    Endwith
    .ChartGroups(1).Gapwidth = 20
    .SeriesCollection(1).Interior.Color = 0xFFFF00
    With .Axes(xlCategory).TickLabels
      With .Font
        .Name = "Verdana"
        .FontStyle = "Normal"
        .Size = 10
        .Color = 0x0000FF
      Endwith
      .Offset = 50
      .Orientation = 90
    Endwith
  Endwith
  .myGraph.Visible=.T.
Endwith
Wait Clear
**** Set the LocaleId to the previous value
=Sys(3006,Val(nlLocaleId))
 
Define Class myForm As Form
  Width=800
  Height=600
  Name='MyForm'
  BackColor = Rgb(255,255,196)
Enddefine

11

Re: rapora grafik ekleme

Çetin Hocam, örneğinizi anladım, form üzerinde grafik ile ilgili güzel bir örnek.
Peki rapor alırken ne yapmam lazım.

Append General graphtest Class MSGraph.Chart Data MCGDATA

yazarak General field'in içini grafik datasıyla doldurdum diyelim. Form içinde kullanırken sorun yok. Rapor bölümünde sadece control source olarak burayı gösterebiliyorum. Başka grafiğin özelliklerine vs. nasıl erişip değiştirebilirim ?

12

Re: rapora grafik ekleme

Rapor icinde mi nasil degistirirsin? Raporda zaten gosterimi dert bunun nasil degistirirsin form kullanmadan bilmiyorum.
(Bu arada o ornegi gonderir gondermez form beni atti. Bir ornek daha gondericem, atilirsam senden biliyorum:)

13

Re: rapora grafik ekleme

Ornegin calismasi icin birkac sart var:
-salescharting.frx diye bir rapor. Icinde OleBoundControl var. Expression: (ChartFile)
-DibAPI32.dll kullaniyor.
dibapi32.dll MS un yayinladigi dosyalardan birisi:

http://download.microsoft.com/download/ … WINCAP.EXE

Visual Fox Pro
*#INCLUDE "mschrt20.h"

#Define VtChChartType3dBar                                0
#Define VtChChartType2dBar                                1
#Define VtChChartType3dLine                               2
#Define VtChChartType2dLine                               3
#Define VtChChartType3dArea                               4
#Define VtChChartType2dArea                               5
#define VtChChartType2dHorizontalBar                      11
 
SET SAFETY off
SELECT cust_id,emp_id,sum(order_net) as totalSale;
  FROM orders ;
  GROUP BY 1,2 ;
  INTO CURSOR empSales ;
  nofilter
SELECT cs.cust_id as customerID,cs.Company, ;
  emp.First_Name - (' '+emp.Last_Name) as employee,;
  sl.totalSale ;
  FROM empSales sl ;
  INNER JOIN customer cs ON cs.cust_id = sl.cust_id ;
  INNER JOIN employee emp ON emp.emp_id = sl.emp_id ;
  ORDER BY 1,3 ;
  INTO CURSOR myReport ;
  readwrite
 
ALTER TABLE myReport ADD COLUMN chartfile m
UPDATE myReport set chartfile = FORCEPATH(TRIM(customerID)+'.bmp',SYS(2023))
SCATTER MEMVAR blank
 
Local lcTemp,loCharter
loCharter = CREATEOBJECT('myCharter')
lcTemp = FORCEPATH(Sys(2015)+".tmp",SYS(2023))
SCAN
  IF !(customerID==m.customerID)
    SCATTER MEMVAR memo
    COPY fields employee,totalSale ;
      to (m.lcTemp) ;
      WHILE customerID==m.customerID ;
      Type Delimited With "" With Tab
    loCharter.Chart2Clipboard(Filetostr(m.lcTemp))
    ClipBoard2BMP(TRIM(m.chartfile))
    SKIP -1 && endscan will skip
  endif
ENDSCAN
 
Report Form salescharting Prev
 
erase (m.lcTemp)
 
PROCEDURE ClipBoard2BMP
  Lparameters tcFileName
  Local llResult,lcFileName
  *
  * Predefined Clipboard Formats
  *
  #Define CF_TEXT             1
  #Define CF_BITMAP           2
  #Define CF_METAFILEPICT     3
  #Define CF_SYLK             4
  #Define CF_DIF              5
  #Define CF_TIFF             6
  #Define CF_OEMTEXT          7
  #Define CF_DIB              8
  #Define CF_PALETTE          9
  #Define CF_PENDATA          10
  #Define CF_RIFF             11
  #Define CF_WAVE             12
  #Define CF_UNICODETEXT      13
  #Define CF_ENHMETAFILE      14
  #Define CF_HDROP            15
  #Define CF_LOCALE           16
  #Define CF_MAX              17
  #Define CF_OWNERDISPLAY     0x0080
  #Define CF_DSPTEXT          0x0081
  #Define CF_DSPBITMAP        0x0082
  #Define CF_DSPMETAFILEPICT  0x0083
  #Define CF_DSPENHMETAFILE   0x008E
 
  Declare short IsClipboardFormatAvailable In win32api Integer cbformat
  Declare Integer GetClipboardData In win32api Integer uFormat
  Declare Integer OpenClipboard In win32Api Integer hWndNewOwner
  Declare Integer CloseClipboard In win32Api
  Declare Integer SaveDIB In DibAPI32.Dll Integer hBitmap, String @ cFileName
  Declare Integer GetSystemPalette In DibAPI32.Dll
 
  lcFileName = Fullpath(Iif(Empty(m.tcFileName),;
    PUTFILE("Save as Bitmap", 'FromClipBoard', "BMP"), ;
    m.tcFileName))
  If !Empty(m.lcFileName) and ( IsClipboardFormatAvailable(CF_DIB) # 0 )
    OpenClipboard(0)
    llResult = ( SaveDIB(GetClipboardData( CF_DIB ), @lcFileName) = 0)
    CloseClipboard()
  Endif
  Return m.llResult
endproc
 
Define Class myCharter As Form
  Height = 400
  Width = 700
  Add Object Chart As OleControl With ;
    Height = 400,Width = 700,OleClass="MSChart20Lib.MSChart.2"
 
  Procedure Chart2Clipboard(tcData)
    _Cliptext = m.tcData
    With This.Chart
      .Editpaste
      .ChartType = VtChChartType2dBar
      .SelectPart(1,1,1,1,1) && VtChPartTypePlot, index1, index2, index3, index4)
      *!*    Copy the chart to the clipboard in Windows Metafile format.
      .repaint
      .EditCopy
      .ToDefaults()
    ENDWITH
  Endproc
Enddefine

14

Re: rapora grafik ekleme

Bu da genel chartFx ornegi. Object browser kullanarak once header dosyasini yaratmaniz gerekiyor.

Visual Fox Pro
PUBLIC oForm

oForm=createobject('form1')
oForm.Show
 
#INCLUDE "mschrt20.h"
Define CLASS form1 AS form
  Top = 0
  Left = 0
  Height = 574
  Width = 784
  DoCreate = .T.
  Caption = "Try to click, drag with Ctrl+Button or button alone"
  Name = "Form1"
 
  Add OBJECT mschart AS olecontrol WITH ;
    Top = 5, ;
    Left = 2, ;
    Height = 451, ;
    Width = 778, ;
    Name = "MsChart", ;
    OleClass = 'MSChart20Lib.MsChart'
 
  Add OBJECT command1 AS commandbutton WITH ;
    Top = 466, ;
    Left = 220, ;
    Height = 27, ;
    Width = 102, ;
    Caption = "Data from array", ;
    Name = "Command1"
 
  Add OBJECT command2 AS commandbutton WITH ;
    Top = 466, ;
    Left = 89, ;
    Height = 27, ;
    Width = 127, ;
    Caption = "Multiply data with 10", ;
    Name = "Command2"
 
  Add OBJECT command3 AS commandbutton WITH ;
    Top = 466, ;
    Left = 325, ;
    Height = 27, ;
    Width = 84, ;
    Caption = "Random data", ;
    Name = "Command3"
 
  Add OBJECT command4 AS commandbutton WITH ;
    Top = 466, ;
    Left = 411, ;
    Height = 27, ;
    Width = 110, ;
    Caption = "Data from cursor", ;
    Name = "Command4"
 
  Add OBJECT command5 AS commandbutton WITH ;
    Top = 466, ;
    Left = 3, ;
    Height = 27, ;
    Width = 84, ;
    Caption = "Title on right", ;
    Name = "Command5"
 
  Add OBJECT command6 AS commandbutton WITH ;
    Top = 466, ;
    Left = 523, ;
    Height = 27, ;
    Width = 100, ;
    Caption = "Legend top", ;
    Name = "Command6"
 
  Add OBJECT combo1 AS combobox WITH ;
    Height = 24, ;
    Left = 72, ;
    Top = 504, ;
    Width = 156, ;
    DisabledItemBackColor = RGB(192,192,192), ;
    DisabledItemForeColor = RGB(128,128,128), ;
    Name = "Combo1"
 
  Add OBJECT combo2 AS combobox WITH ;
    Height = 24, ;
    Left = 72, ;
    Top = 530, ;
    Width = 156, ;
    Name = "Combo2"
 
  Add OBJECT label1 AS label WITH ;
    Caption = "Perspective", ;
    Height = 17, ;
    Left = -1, ;
    Top = 535, ;
    Width = 72, ;
    Name = "Label1"
 
  Add OBJECT label2 AS label WITH ;
    Caption = "Chart Type", ;
    Height = 17, ;
    Left = 7, ;
    Top = 507, ;
    Width = 61, ;
    Name = "Label2"
 
  Add OBJECT label3 AS label WITH ;
    Caption = "Elevation", ;
    Height = 17, ;
    Left = 235, ;
    Top = 508, ;
    Width = 60, ;
    Name = "Label3"
 
  Add OBJECT label4 AS label WITH ;
    Caption = "Rotation", ;
    Height = 17, ;
    Left = 235, ;
    Top = 529, ;
    Width = 48, ;
    Name = "Label4"
 
  Add OBJECT spinner1 AS spinner WITH ;
    Height = 24, ;
    KeyboardHighValue = 90, ;
    KeyboardLowValue = 0, ;
    Left = 288, ;
    SpinnerHighValue =  90.00, ;
    SpinnerLowValue =   0.00, ;
    Top = 503, ;
    Width = 53, ;
    Value = 30, ;
    Name = "Spinner1"
 
  Add OBJECT spinner2 AS spinner WITH ;
    Height = 24, ;
    Increment =  10.00, ;
    KeyboardHighValue = 360, ;
    KeyboardLowValue = 0, ;
    Left = 288, ;
    SpinnerHighValue = 360.00, ;
    SpinnerLowValue =   0.00, ;
    Top = 528, ;
    Width = 53, ;
    Name = "Spinner2"
 
  Add OBJECT label5 AS label WITH ;
    AutoSize = .T., ;
    Caption = "DepthToHeightRatio", ;
    Height = 17, ;
    Left = 468, ;
    Top = 504, ;
    Width = 114, ;
    Name = "Label5"
 
  Add OBJECT label6 AS label WITH ;
    Caption = "WidthToHeightRatio", ;
    Height = 17, ;
    Left = 468, ;
    Top = 528, ;
    Width = 112, ;
    Name = "Label6"
 
  Add OBJECT label7 AS label WITH ;
    Caption = "xGap", ;
    Height = 17, ;
    Left = 348, ;
    Top = 507, ;
    Width = 36, ;
    Name = "Label7"
 
  Add OBJECT label8 AS label WITH ;
    Caption = "zGap", ;
    Height = 17, ;
    Left = 348, ;
    Top = 528, ;
    Width = 36, ;
    Name = "Label8"
 
  Add OBJECT spinner3 AS spinner WITH ;
    Height = 24, ;
    Increment =  10.00, ;
    KeyboardHighValue = 100, ;
    KeyboardLowValue = 0, ;
    Left = 384, ;
    SpinnerHighValue = 100.00, ;
    SpinnerLowValue =   0.00, ;
    Top = 504, ;
    Width = 71, ;
    Name = "Spinner3"
 
  Add OBJECT spinner4 AS spinner WITH ;
    Height = 24, ;
    Increment =  10.00, ;
    KeyboardHighValue = 100, ;
    KeyboardLowValue = 0, ;
    Left = 384, ;
    SpinnerHighValue = 100.00, ;
    SpinnerLowValue =   0.00, ;
    Top = 529, ;
    Width = 71, ;
    Name = "Spinner4"
 
  Add OBJECT spinner5 AS spinner WITH ;
    Height = 24, ;
    KeyboardHighValue = 10, ;
    KeyboardLowValue = 1, ;
    Left = 586, ;
    SpinnerHighValue =  10.00, ;
    SpinnerLowValue =   1.00, ;
    Top = 499, ;
    Width = 40, ;
    Name = "Spinner5"
 
  Add OBJECT spinner6 AS spinner WITH ;
    Height = 24, ;
    KeyboardHighValue = 10, ;
    KeyboardLowValue = 1, ;
    Left = 586, ;
    SpinnerHighValue =  10.00, ;
    SpinnerLowValue =   1.00, ;
    Top = 524, ;
    Width = 40, ;
    Name = "Spinner6"
 
  Procedure Init
    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
 
    With thisform.mschart
&& Set Chart parameters using methods.
      rowLabelCount = 2
      columnLabelCount = 2
      .rowCount = 3*4
      .columnCount = alen(arrCars)*alen(colors)
      Scan
        .Row = recno()
        For ix=3 to fcount()
          .Column = ix-2
          .Data = eval(field(ix))
        Endfor
      Endscan
    Endwith
    With thisform.mschart.DataGrid
      rowLabelCount = 2
      columnLabelCount = 2
      rowCount = 3*4
      ColumnCount = alen(arrCars)*alen(colors)
      .SetSize(rowLabelCount, columnLabelCount, rowCount, ColumnCount )
&& Then assign labels to first Level.
      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
 
    Thisform.mschart.ShowLegend = .T.
  Endproc
 
 
  Procedure command1.Click
    Dimension arrData(4, 5)
    arrData(1, 1) = "Jan"   && Set the labels in the first series.
    arrData(2, 1) = "Feb"
    arrData(3, 1) = "Mar"
    arrData(4, 1) = "Apr"
 
    arrData(1, 2) = 8
    arrData(2, 2) = 4
    arrData(3, 2) = 0.3
    arrData(4, 2) = 6
 
    arrData(1, 3) = 0.2
    arrData(2, 3) = 3
    arrData(3, 3) = 6.3
    arrData(4, 3) = 5
 
    arrData(1, 4) = 1
    arrData(2, 4) = 2
    arrData(3, 4) = 3
    arrData(4, 4) = 4
 
    arrData(1, 5) = 2
    arrData(2, 5) = 3
    arrData(3, 5) = 6
    arrData(4, 5) = 5
 
    #Define TABULATE chr(9)
    #Define CRLF chr(13)+chr(10)
    m.Str = ''
    For ix = 1 to 4
      For jx = 1 to 5
        m.Str = m.Str + transform(arrData[ix,jx])+TABULATE
      Endfor
      m.Str = left(m.Str,len(m.Str)-1)+CRLF
    Endfor
    _Cliptext = m.Str
    Thisform.mschart.Editpaste
    Thisform.mschart.ShowLegend
  Endproc
 
 
  Procedure command2.Click
    With thisform.mschart
      For icolumn = 1 To .ColumnCount
        For irow = 1 To .rowCount
          .Column = icolumn
          .Row = irow
          .Data = val(.Data) * 10
        Endfor
      Endfor
      .DataGrid.RowLabel(1,1) = 'Hello'
    Endwith
 
  Endproc
 
 
  Procedure command3.Click
    With thisform.mschart.DataGrid
&& Set Chart parameters using methods.
      rowLabelCount = 2
      columnLabelCount = 2
      rowCount = 6
      ColumnCount = 6
      .SetSize(rowLabelCount, columnLabelCount, rowCount, ColumnCount )
&& Randomly fill in the data.
      .RandomDataFill
&& Then assign labels to second Level.
      labelIndex = 2
      Column = 1
      .ColumnLabel(column, labelIndex) = "Product 1"
      Column = 4
      .ColumnLabel(column, labelIndex) = "Product 2"
      Row = 1
      .RowLabel(row, labelIndex) = "1994"
      .RowLabel(row, 1) = "Dummy label"
      Row = 4
      .RowLabel(row, labelIndex) = "1995"
    Endwith
    Thisform.mschart.ShowLegend = .T.
  Endproc
 
 
  Procedure command4.Click
    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
    Browse title 'Data that would be charted'
 
    With thisform.mschart
&& Set Chart parameters using methods.
      rowLabelCount = 2
      columnLabelCount = 2
      .rowCount = 3*4
      .columnCount = alen(arrCars)*alen(colors)
      Scan
        .Row = recno()
        For ix=3 to fcount()
          .Column = ix-2
          .Data = eval(field(ix))
        Endfor
      Endscan
    Endwith
    With thisform.mschart.DataGrid
      rowLabelCount = 2
      columnLabelCount = 2
      rowCount = 3*4
      ColumnCount = alen(arrCars)*alen(colors)
      .SetSize(rowLabelCount, columnLabelCount, rowCount, ColumnCount )
&& Then assign labels to first Level.
        With thisform.mschart.Plot.Axis(VtChAxisIdX).Labels(2).TextLayout
        .Orientation = VtOrientationUp
        .VertAlignment = VtVerticalAlignmentCenter
        .HorzAlignment = VtHorizontalAlignmentCenter
        endwith
 
      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
 
    Thisform.mschart.ShowLegend = .T.
  Endproc
 
 
  Procedure command5.Click
    With thisform.mschart.Title
      With .VtFont
        .Name = "Times New Roman"
        .Size = 18
        .Style = bitor(VtFontStyleBold, VtFontStyleItalic)
        .Effect = VtFontEffectUnderline
        .VtColor.Set( 255, 0, 0 )
      Endwith
      With .TextLayOut
        .Orientation = VtOrientationUp
        .VertAlignment = VtVerticalAlignmentCenter
        .HorzAlignment = VtHorizontalAlignmentCenter
      Endwith
      .Location.Visible = .T.
      .Location.LocationType = VtChLocationTypeRight
    Endwith
    Thisform.mschart.TitleText = 'Chart Title Here'
  Endproc
 
  Procedure command6.Click
    Thisform.legendpos('TOP'$upper(this.Caption))
    This.Caption = iif('TOP'$upper(this.Caption),'Legend bottom','Legend top')
  Endproc
 
  Procedure legendpos
    * Put legend in top-right or bottom-right
    Lparameters tlTop
    With ThisForm.mschart
      lnCurHeight = .Height * 15
      lnCurWidth = .Width * 15
      With .Legend
        .Location.Visible = .t.
        .Location.LocationType = 8
        With .Location.Rect
          lnHgt = .Max.Y-.Min.Y
          lnWdt = .Max.X-.Min.X
          .Max.X = lnCurWidth
          .Min.X = lnCurWidth - lnWdt
          .Min.Y = iif(tlTop, lnCurHeight - lnHgt, 0)
          .Max.Y = iif(tlTop, lnCurHeight,lnHgt)
        Endwith
      Endwith
    Endwith
  Endproc
 
  Procedure combo1.Init
    With this
      .ColumnCount = 2
      .Boundcolumn=2
      .BoundTo = .t.
      .ColumnWidths = '100,20'
      .AddListItem('3dBar',1,1)
      .AddListItem(transform(VtChChartType3dBar),1,2)
      .AddListItem('2dBar',2,1)
      .AddListItem(transform(VtChChartType2dBar),2,2)
      .AddListItem('3dLine',3,1)
      .AddListItem(transform(VtChChartType3dLine),3,2)
      .AddListItem('2dLine',4,1)
      .AddListItem(transform(VtChChartType2dLine),4,2)
      .AddListItem('3dArea',5,1)
      .AddListItem(transform(VtChChartType3dArea),5,2)
      .AddListItem('2dArea',6,1)
      .AddListItem(transform(VtChChartType2dArea),6,2)
      .AddListItem('3dStep',7,1)
      .AddListItem(transform(VtChChartType3dStep),7,2)
      .AddListItem('2dStep',8,1)
      .AddListItem(transform(VtChChartType2dStep),8,2)
      .AddListItem('3dCombination',9,1)
      .AddListItem(transform(VtChChartType3dCombination),9,2)
      .AddListItem('2dCombination',10,1)
      .AddListItem(transform(VtChChartType2dCombination),10,2)
      .AddListItem('3dHorizontalBar',11,1)
      .AddListItem('\'+transform(VtChChartType3dHorizontalBar),11,2)
      .AddListItem('2dHorizontalBar',12,1)
      .AddListItem('\'+transform(VtChChartType2dHorizontalBar),12,2)
      .AddListItem('3dClusteredBar',13,1)
      .AddListItem('\'+transform(VtChChartType3dClusteredBar),13,2)
      .AddListItem('3dPie',14,1)
      .AddListItem('\'+transform(VtChChartType3dPie),14,2)
      .AddListItem('2dPie',15,1)
      .AddListItem(transform(VtChChartType2dPie),15,2)
      .AddListItem('3dDoughnut',16,1)
      .AddListItem('\'+transform(VtChChartType3dDoughnut),16,2)
      .AddListItem('2dXY',17,1)
      .AddListItem(transform(VtChChartType2dXY),17,2)
      .AddListItem('2dPolar',18,1)
      .AddListItem('\'+transform(VtChChartType2dPolar),18,2)
      .AddListItem('2dRadar',19,1)
      .AddListItem('\'+transform(VtChChartType2dRadar),19,2)
      .AddListItem('2dBubble',20,1)
      .AddListItem('\'+transform(VtChChartType2dBubble),20,2)
      .AddListItem('2dHiLo',21,1)
      .AddListItem('\'+transform(VtChChartType2dHiLo),21,2)
      .AddListItem('2dGantt',22,1)
      .AddListItem('\'+transform(VtChChartType2dGantt),22,2)
      .AddListItem('3dGantt',23,1)
      .AddListItem('\'+transform(VtChChartType3dGantt),23,2)
      .AddListItem('3dSurface',24,1)
      .AddListItem('\'+transform(VtChChartType3dSurface),24,2)
      .AddListItem('2dContour',25,1)
      .AddListItem('\'+transform(VtChChartType2dContour),25,2)
      .AddListItem('3dScatter',26,1)
      .AddListItem('\'+transform(VtChChartType3dScatter),26,2)
      .AddListItem('3dXYZ',27,1)
      .AddListItem('\'+transform(VtChChartType3dXYZ),27,2)
      .AddListItem('Count',28,1)
      .AddListItem('\'+transform(VtChChartTypeCount),28,2)
    Endwith
  Endproc
 
 
  Procedure combo1.Valid
    Thisform.mschart.ChartType = val(this.Value)
    If val(this.Value) = VtChChartType2dPie
      For Each serX In ThisForm.mschart.Plot.SeriesCollection
        With serX.Datapoints.Item(-1).DatapointLabel
          .Component = VtChLabelComponentPercent  && Show as percent
          .LocationType = VtChLabelLocationTypeInside && Inside pie slice
          .PercentFormat = '0%'
        Endwith
      Endfor
    Else
      For Each serX In ThisForm.mschart.Plot.SeriesCollection
        With serX.Datapoints.Item(-1).DatapointLabel
          .LocationType = VtChLabelLocationTypeNone && No label
        Endwith
      Endfor
    Endif
  Endproc
 
 
  Procedure combo2.Valid
    With thisform.mschart
      * Set the chart to a 3D type.
      .ChartType = VtChChartType3dBar
      * Change the projection when clicked.
      .Plot.Projection = this.ListIndex-1
    Endwith
  Endproc
 
 
  Procedure combo2.Init
    With this
      .AddListItem("VtProjectionTypePerspective")
      .AddListItem("VtProjectionTypeOblique")
      .AddListItem("VtProjectionTypeOrthogonal")
      .AddListItem("VtProjectionTypeFrontal")
      .AddListItem("VtProjectionTypeOverhead")
    Endwith
  Endproc
 
 
  Procedure spinner1.When
    This.Value = ThisForm.mschart.Plot.View3d.Elevation
  Endproc
 
 
  Procedure spinner1.InteractiveChange
    Thisform.mschart.Plot.View3d.Elevation = this.value
  Endproc
 
 
  Procedure spinner2.When
    This.Value = ThisForm.mschart.Plot.View3d.Rotation
  Endproc
 
 
  Procedure spinner2.InteractiveChange
    Thisform.mschart.Plot.View3d.Rotation = this.value
  Endproc
 
 
  Procedure spinner3.InteractiveChange
    Thisform.mschart.Plot.xGap = this.value/100
  Endproc
 
 
  Procedure spinner4.InteractiveChange
    Thisform.mschart.Plot.zGap = this.value/100
  Endproc
 
 
  Procedure spinner5.InteractiveChange
    Thisform.mschart.Plot.DepthToHeightRatio = this.value
  Endproc
 
 
  Procedure spinner6.InteractiveChange
    Thisform.mschart.Plot.WidthToHeightRatio = this.value
  Endproc
 
Enddefine

15 Son düzenleyen, taRKan (29.10.2007 13:15:27)

Re: rapora grafik ekleme

Object Browser'dan mschrt20.h dosyasını oluşturamadım ama internetten senin oluşturduğun dosyayı buldum smile

Çetin'in bu güzel örneği için gerekli olan mschrt20.h dosyasını yine Çetin'in UT'ye gönderdiği dosyadan alabilirsiniz. Adresi:

http://www.universalthread.com/wconnect … 54,33,9979

Teşekkürler Çetin

/o---------------------o\
     www.haser.com
\o---------------------o/

16

Re: rapora grafik ekleme

O zaman ben de nasil olusturacaginiz analatayim:)

Modi command MSchart20.h [enter]

Bos kod penceresi acildi bekliyor.
Object browser ikonuna tiklayin.
En soldaki ikona tiklayin. COM Libraries tabini secin. "Microsoft Chart Control 6.0 SP4" bulup isaretleyin. OK.
Goruntulenen MSCart20Lib'i + isaretine kilkleyerek acin
"Constants" nodunu bos bekleyen kod penceresinin uzerine surukleyip birakin:)

17

Re: rapora grafik ekleme

O kadar da baktım! smile

/o---------------------o\
     www.haser.com
\o---------------------o/