Delphi Tutorial


Delphi Tutorial Graphic Charts - Simple steps to create Delphi chart.

Delphi Tutorial Graphic Charts - Simple steps to create Delphi chart.

 

Download this example

Use following simple steps to start:

1. Put chart component on the form

2. Double click on chart, then you will see chart editing dialog box.

3. Click add button in series tab sheet.

4. Select the chart style from the list (Line, Bar, Pie …..)

Put following code to add data into the chart

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;

DOWNLOAD this example

Click here to download this complete example for Delphi 6. (File size 5KB)

 

Go top

 


Previous Page First Page Next Page
 
Copyright © 2003 digitalcoding.com. All rights reserved.