I try to create a simple piechart for odd and even numbers
What do you mean with "piechart for odd and even numbers"?
Suppose there is an opinion poll for one of several options to choose from:
- 10 voters are for option "A"
- 23 voters are for option "B"
- 2 voters are for option "C".
Add a TPieSeries to a TChart and add these data to the Pieseries, for example in the OnCreate event of the form:
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1PieSeries1.AddXY(0, 10, 'A');
Chart1PieSeries1.AddXY(0, 23, 'B');
Chart1PieSeries1.AddXY(0, 2, 'C');
end;
Let's discuss the arguments from right to left: the last argument is the name of the option selected. The second argument is the number of voters for this option. The first argument is the distance of the pie from the center. When it is zero all pies touch each other in the center of the circle. When you increase the first parameter the pie is moved away from the center. The first parameter is measured in units of the pie radius, so be moderate in using non-zero values. The following example moves pie "C" away from the center by a quarter of the pie radius. Note that the "Exploded" property must be set to true for this to become effective.
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1PieSeries1.AddXY(0, 10, 'A');
Chart1PieSeries1.AddXY(0, 23, 'B');
Chart1PieSeries1.AddXY(0.25, 2, 'C');
Chart1PieSeries1.Exploded := true;
end;