المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : استغلال مكون TChart لعرض بيانات


kachwahed
25-02-2009, 11:25 AM
بسم الله الرحمن الرحيم
السلام عليكم
أظن أن هذا هو القسم المناسب...
هذا مثال صغير حول طريقة استعمال مكونات TChart لعرض الأشكال والمخططات البيانية.
(*Open a new project inser TChart component and follow this instructions:
* Double click on chart, then you will see chart editing dialog box.
* Click add button in series tab sheet.
* Select the chart style from the list (Line, Bar, Pie ..)*)

procedure TForm1.Button1Click(Sender: TObject);
begin
{ function AddXY(Const AXValue, AYValue: Double;
Const AXLabel: String; AColor: TColor) : Longint;

This function inserts a new point in the Series.
The new point has X and Y values. The AXLabel
parameter is optional (can be empty ''). The AColor
parameter is optional (can be clTeeColor).
The function returns the new point position in the
Values list. }
Chart1.Series[0].AddXY(10, 20, '', clTeeColor);
Chart1.Series[0].AddXY(15, 50, '', clTeeColor);
Chart1.Series[0].AddXY(20, 30, '', clTeeColor);
Chart1.Series[0].AddXY(25, 70, '', clTeeColor);
Chart1.Series[0].AddXY(30, 10, '', clTeeColor);
Chart1.Series[0].AddXY(35, 50, '', clTeeColor);
Chart1.Series[0].AddXY(40, 45, '', clTeeColor);
Chart1.Series[0].AddXY(45, 10, '', clTeeColor);

{ Or you can write following code using "With" statement.
Its much easier than repeating everything again and again.

With Chart1.Series[0] Do
Begin
AddXY(10, 20, '', clTeeColor);
AddXY(15, 50, '', clTeeColor);
AddXY(20, 30, '', clTeeColor);
AddXY(25, 70, '', clTeeColor);
AddXY(30, 10, '', clTeeColor);
AddXY(35, 50, '', clTeeColor);
AddXY(40, 45, '', clTeeColor);
AddXY(45, 10, '', clTeeColor);
End;
}
end;
يمكن استعمال مثل هذا الكود لربطه مع بيانات أحد جداول قواعد البيانات.