这里有一个简单的示例,向您展示如何使用 TeeChart 绘制与您图片中的相似的 TDonutSeries。这是它的样子:
这是我用来生成它的代码。它基本上是一个具有 2 个值和一个宽笔的 TDonutSeries。以及两个用于文本的 TAnnotationTools:
uses TeCanvas, TeeDonut, TeeTools, Series;
procedure TForm1.FormCreate(Sender: TObject);
var donut1: TDonutSeries;
annot1, annot2: TAnnotationTool;
tmpX, tmpY: Integer;
begin
(Chart1.Canvas as TGDIPlusCanvas).AntiAliasText:=gpfBest;
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
with Chart1.Foot do
begin
Text.Text:='G1';
Font.Color:=clBlack;
Font.Style:=[];
Font.Size:=25;
end;
donut1:=Chart1.AddSeries(TDonutSeries) as TDonutSeries;
annot1:=Chart1.Tools.Add(TAnnotationTool) as TAnnotationTool;
annot2:=Chart1.Tools.Add(TAnnotationTool) as TAnnotationTool;
with donut1 do
begin
Add(33, '', clWhite);
Add(66, '', RGB(0, 178, 247));
Pen.Color:=RGB(0, 178, 247);
Pen.Width:=8;
RotationAngle:=90;
Marks.Visible:=false;
CustomXRadius:=120;
CustomYRadius:=120;
end;
with annot1 do
begin
Text:='56%';
Shape.Transparent:=true;
Shape.Font.Size:=25;
end;
with annot2 do
begin
Text:='33%';
Shape.Transparent:=true;
Shape.Font.Size:=15;
end;
Chart1.Draw;
with annot1 do
begin
Shape.Left:=donut1.CircleXCenter-(Shape.Width div 2);
Shape.Top:=donut1.CircleYCenter-(Shape.Height div 2);
end;
with annot2 do
begin
donut1.AngleToPos(180, donut1.CustomXRadius, donut1.CustomYRadius, tmpX, tmpY);
Shape.Left:=tmpX-(Shape.Width div 2)+30;
Shape.Top:=tmpY-(Shape.Height div 2)+30;
end;
end;
如果您更喜欢使用系列标记而不是 TAnnotationTools,您可以尝试如下设置:
donut1.Marks.Transparent:=True;
donut1.Marks.Font.Size:=20;
donut1.Marks.Callout.ArrowHead:=ahSolid;