How to create charts with manually inserted values

Data Aware Charts

If values are manually inserted it means that you do not want TeeChart to automatically retrieve the Series points from a Table or Query.

1) Place a TChart component in a Delphi Form.

2) Add a Series component via the Chart Editor. (For example, you can choose a BarSeries component.)

3) In your Form1.OnCreate event (or in a Button1.OnClick event), type the following code:

Series1.Clear; // Where Series1 is your Bar series

Series1.Add( 25 , 'Barcelona'     , clTeeColor );
Series1.Add( 50 , 'Rome'          , clTeeColor );
Series1.Add( 30 , 'San Francisco' , clTeeColor );
Series1.Add( 50 , 'New York'      , clTeeColor );
Series1.Add( 40 , 'Los Angeles'   , clTeeColor );

Series1.Add( 35 , 'London' , clTeeColor );

That's it.

Now lets add a new Line Series component (Series2):

4) Place a Line Series component in the Form.

5) Add the following code to the previous code:

Series2.Clear; // Where Series2 is your LineSeries

Series2.Add( 25 , '' , clTeeColor );
Series2.Add( 50 , '' , clTeeColor );
Series2.Add( 30 , '' , clTeeColor );
Series2.Add( 50 , '' , clTeeColor );
Series2.Add( 40 , '' , clTeeColor );
Series2.Add( 35 , '' , clTeeColor );

(Notice you do not need to insert the Horizontal Labels again).

clTeeColor is a TeeChart color constant that means "draw the point in the default color".

You can assign a specific color (clRed, clBlue, etc) to each point or you can set the LineSeries1.ColorEachPoint property to True in order to automatically draw each point with a different color.

If you have X (Horizontal) Coordinates:

Replace the AddY method with AddXY:

Series2.AddXY( 15.2 , 25.4 , 'Barcelona' , clBlue );

Other Chart Series types:

Other Series types may use the same methods to add points:

PieSeries1.Add( 333 , 'Sales' , clTeeColor );

Whilst some series that rely on more inputs have series specific methods to add points:

BubbleSeries1.AddBubble( 15.2 , 25.4 , 13 , '' , clRed ); {being 13 the bubble radius}