Page 1 of 1
Annotation and an Arrow
Posted: Wed Apr 29, 2009 4:55 pm
by 10546565
I would like to add an annotation to a chart, which is pretty easy. But I need a few more features:
1) I need to add an arrow from the annotation to a specific location on the chart with the arrow connected to the closes point of the annotation; and
2) I would like to allow the user to move the annotation by dragging it to a new location.
Can items #1 and #2 be done?
Thank you,
Ed Dressel
Posted: Thu Apr 30, 2009 8:43 am
by yeray
Hi Ed,
One solution could be allowing drag to your annotation, look at
here. But I'm afraid that you should control your arrow position manually.
Another solution could be using a dummy point series with pointers hided and with DragMarks tool associated. This could be an example:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var APosition: TSeriesMarkPosition;
i: Integer;
begin
Chart1.View3D := false;
for i:=0 to 24 do
Series1.Add(random*200);
ChartTool1.Series := Series2;
Series2.AddXY(10,100,'Your custom text');
Series2.Marks.Visible := true;
Chart1.Draw;
Series2.Pointer.Visible := false;
Series2.ShowInLegend := false;
Series2.Marks.Arrow.Color := clRed;
with Series2.Marks.Positions[0] do
begin
Custom := true;
LeftTop.X := LeftTop.X+100;
LeftTop.Y := LeftTop.Y-100;
ArrowTo.X := ArrowTo.X+100;
ArrowTo.Y := ArrowTo.Y-100;
end;
Chart1.Axes.Bottom.LabelStyle := talValue;
end;
If you don't like this, I'm afraid I can't think on anything easiest than drawing directly to the canvas.
Posted: Thu Apr 30, 2009 2:25 pm
by 10546565
If you don't like this, I'm afraid I can't think on anything easiest than drawing directly to the canvas.
Thanks for the ideas. Is there an example of drawing my own arrow? e.g. what even should I used?
Posted: Thu Apr 30, 2009 3:21 pm
by yeray
Hi Ed,
Here you have another possibility: The Rectangle Tool that is pretty similar than the Annotation but it allows dragging "out of the box".
Code: Select all
uses series, TeeTools;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.AddSeries(TPointSeries.Create(self));
Chart1[0].FillSampleValues(50);
Chart1.Tools.Add(TRectangleTool.Create(self));
with (Chart1.Tools[0] as TRectangleTool) do
begin
Text := 'My custom text';
Left := 200;
Top := 200;
Callout.Arrow.Visible := true;
Callout.Arrow.Color := clRed;
Callout.XPosition := 100;
Callout.YPosition := 100;
end;
end;
If you still don't like it, I'll try to do a "custom drawing solution".