Simple steps to create Delphi chart

Simple steps to create Delphi chart

Simple steps to create Delphi chart

This Delphi graphic tutorial demonstrates how to create a simple charts using TChart component.

DownloadDownload This Tutorials

Bookmark:

Simple steps to create Delphi chart

Use following simple steps to start your first chart using Delphi TChart component:

  • Put chart component on the form
  • 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 ..)

Delphi chart

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 Delphi Tutorials.

Download materials for this article (Delphi - Tutorials)

Download - delphi-chart.zipdelphi-chart.zip
       File size: 5 KB, File type: zip
       Total downloads: 1387, Upload date: February 11 - 2009

Luis :: February 19-2009 :: 08:31 PM

Hello, Would you please give me some hints on how to allow a user to choose a chart style, I mean I need a code for example i can select combobox and type 3 options to plot a chart.

Thanks

Sibusiso :: March 10-2009 :: 09:34 AM

How to make the chart to be visible in intraweb

Widakdov :: November 09-2009 :: 03:49 AM

Dear digital coding ,

How to create a simulated chart using delphi

Leave a comment