Konu: Grafik - ornek
Baska bir nedenle elimden geciyordu buraya atayim dedim, hem sessizligi biaz bozmus olayim:)
*#INCLUDE "mschrt20.h"
#Define VtChChartType3dBar 0
#Define VtChChartType2dBar 1
#Define VtChLabelComponentValue 1 && The value of the data point appears in the label.
#Define VtChLabelComponentPercent 2 && The value of the data point is displayed in the label as a percentage of the total value of the series.
#Define VtOrientationHorizontal 0 && Horizontal text
#Define VtOrientationVertical 1 && Vertical text
#Define VtOrientationUp 2 && Up oriented text
#Define VtOrientationDown 3 && Down oriented text
#Define VtChLabelLocationTypeNone 0 && Label Location - None
#Define VtChLabelLocationTypeAbovePoint 1 && Label Location - AbovePoint
#Define VtChLabelLocationTypeBelowPoint 2 && Label Location - BelowPoint
#Define VtChLabelLocationTypeCenter 3 && Label Location - Center
#Define VtChLabelLocationTypeBase 4 && Label Location - Base
#Define VtChLabelLocationTypeInside 5 && Label Location - Inside pie or doughnut
#Define VtChLabelLocationTypeOutside 6 && Label Location - Outside pie or doughnut
#Define VtChLabelLocationTypeLeft 7 && Label Location - Left
#Define VtChLabelLocationTypeRight 8 && Label Location - Right
Public loCharter
loCharter = Createobject('myCharter')
loCharter.Show
Define Class myCharter As Form
DataSession = 2
Height = 600
Width = 800
Add Object myGrid As Grid With ;
left=10,Top=10,Height=580,Width=360,Anchor=1+2+4+128
Add Object Chart As OleControl With ;
left=375,Top=10,Height=580,Width=415,Anchor=1+8+4+32, ;
OleClass="MSChart20Lib.MSChart.2"
Procedure Load
Use (_samples+'data\Customer')
Endproc
Procedure Init
This.UpdateChart()
Endproc
Procedure myGrid.AfterRowColChange
Lparameters nColIndex
* VFP7 and up - earlier no if control
If This.RowColChange%2 = 1
Thisform.UpdateChart()
Endif
Endproc
Procedure UpdateChart
Select ;
emp.First_Name - (' '+emp.Last_Name) As employee,;
sum(order_net) As totalSale ;
FROM (_samples+'data\orders') ord ;
INNER Join (_samples+'data\employee') emp On emp.emp_id = ord.emp_id ;
WHERE ord.cust_id == customer.cust_id ;
GROUP By 1 ;
ORDER By 1 ;
INTO Cursor crsChartData
If _Tally > 0
With Thisform.Chart
.ChartType = VtChChartType2dBar && VtChChartType2dBar
rowLabelCount = 1
rowCount = Reccount()
columnLabelCount = 0
ColumnCount = 1
.DataGrid.SetSize(m.rowLabelCount, m.columnLabelCount, ;
m.rowCount, m.ColumnCount )
.Column = 1
Scan
.Row = Recno()
.Data = totalSale
.DataGrid.RowLabel(Recno(),1) = employee
Endscan
For Each serX In .Plot.SeriesCollection
With serX.Datapoints.Item(-1).DatapointLabel
.Component = VtChLabelComponentValue && Show value
.LocationType = VtChLabelLocationTypeAbovePoint && Above
.ValueFormat = '$#,##0.00'
Endwith
Endfor
.Visible = .T.
Endwith
Else
Thisform.Chart.Visible = .F.
Endif
Endproc
Enddefine