
The pointer on at ~2 o'clock indicates their position (117 out of 150).
Can that be done with a TChart series? If so, how?
Much appreciated,
Ed Dressel
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |
Code: Select all
uses TeeDonut, Series, TeeTools, TeCanvas;
var myDonut: TDonutSeries;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=False;
Chart1.Legend.Visible:=False;
Chart1.Title.Visible:=False;
Chart1.Gradient.Visible:=False;
Chart1.Color:=clWhite;
Chart1.Hover.Visible:=False;
myDonut:=Chart1.AddSeries(TDonutSeries) as TDonutSeries;
with myDonut do
begin
AddPie(40, 'On Track', RGB(88, 150, 30));
AddPie(10, 'Good', RGB(192, 200, 50));
AddPie(10, 'Far', RGB(255, 200, 40));
AddPie(50, 'Needs Attention', RGB(246, 69, 50));
Shadow.Visible:=False;
AngleSize:=180;
Pen.Color:=clWhite;
Marks.Font.Color:=TTeeCanvas.ColorFrom(Marks.Font.Color,255);
Marks.Font.Size:=11;
Marks.ArrowLength:=-150;
Marks.Arrow.Visible:=False;
Marks.Transparent:=True;
DonutPercent:=60;
BeforeDrawValues:=Series1BeforeDrawValues;
AfterDrawValues:=Series1AfterDrawValues;
end;
Chart1.Draw;
with Chart1.Tools.Add(TAnnotationTool) as TAnnotationTool do
begin
Text:='117';
Shape.Font.Color:=RGB(88, 150, 30);
Shape.Font.Size:=50;
Shape.Transparent:=True;
Shape.CustomPosition:=True;
Chart1.Canvas.Font.Assign(Shape.Font);
Shape.Left:=myDonut.CircleXCenter - Chart1.Canvas.TextWidth(Text) div 2;
Shape.Top:=myDonut.CircleYCenter - Chart1.Canvas.TextHeight(Text) div 2;
end;
end;
procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect(0,225,Chart1.Width, Chart1.Height);
end;
procedure TForm1.Series1AfterDrawValues(Sender: TObject);
var triangle: array of TPoint;
tmpAngle: Double;
tmpX, tmpY, i: Integer;
begin
with Chart1.Canvas do
begin
Brush.Color:=Chart1.Color;
Pen.Visible:=False;
tmpAngle:=40;
SetLength(triangle, 3);
myDonut.AngleToPos(tmpAngle*TeePiStep, myDonut.XRadius*(myDonut.DonutPercent+7)*0.01, myDonut.YRadius*(myDonut.DonutPercent+7)*0.01, tmpX, tmpY);
triangle[0].X:=tmpX;
triangle[0].Y:=tmpY;
myDonut.AngleToPos((tmpAngle+5)*TeePiStep, myDonut.XRadius*(myDonut.DonutPercent-1)*0.01, myDonut.YRadius*(myDonut.DonutPercent-1)*0.01, tmpX, tmpY);
triangle[1].X:=tmpX;
triangle[1].Y:=tmpY;
myDonut.AngleToPos((tmpAngle-5)*TeePiStep, myDonut.XRadius*(myDonut.DonutPercent-1)*0.01, myDonut.YRadius*(myDonut.DonutPercent-1)*0.01, tmpX, tmpY);
triangle[2].X:=tmpX;
triangle[2].Y:=tmpY;
Polygon(triangle);
Font.Assign(myDonut.Marks.Font);
Font.Color:=clWhite;
for i:=0 to myDonut.Count-1 do
begin
myDonut.AngleToPos(myDonut.Angles[i].MidAngle, myDonut.XRadius*myDonut.DonutPercent*0.015, myDonut.YRadius*myDonut.DonutPercent*0.015, tmpX, tmpY);
RotateLabel(tmpX, tmpY, myDonut.Labels[i], ((myDonut.Angles[i].MidAngle)/TeePiStep)-90);
end;
end;
end;
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |