Annotation Tool drawing problem

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Bert B.
Newbie
Newbie
Posts: 69
Joined: Fri Jun 15, 2007 12:00 am

Annotation Tool drawing problem

Post by Bert B. » Tue Nov 08, 2011 9:09 am

Hello,

In the attached sample project I have 2 chart with 2 Annotation tools with a custom position.
Following advise in this forum the position of the Annotation tool is set in the OnAfterDraw event of the chart.
With the checkbox Chart1 can be made (in)visible. In the following OnAfterDraw event the Annotation tool is not drawn in the correct position, only after a second OnAfterDraw event.
What do I have to do to draw the Annotion tool in the correct place after (un)checking the checkbox?
sshot-2.png
sshot-2.png (33.35 KiB) Viewed 7691 times
sshot-3.png
sshot-3.png (33.85 KiB) Viewed 7690 times
Regards,
Bert
Attachments
TeeChartAnnotationTool.rar
(1.94 KiB) Downloaded 535 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Annotation Tool drawing problem

Post by Yeray » Wed Nov 09, 2011 9:57 am

Hello Bert,

I've found a quite ugly workaround:

Code: Select all

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  Chart1.Visible := CheckBox1.Checked;

  Chart2.Draw;
  ChartTool2.Repaint;
end;
Or another one maybe a little bit prettier:

Code: Select all

var Annotation2OldVal: Integer;

procedure TForm1.FormShow(Sender: TObject);
begin
   LabelVersion.Caption := TeeMsg_Version;
   Annotation2OldVal:=-1;
end;

procedure TForm1.Chart2AfterDraw(Sender: TObject);
begin
  with ChartTool2 do
  begin
    Top := ParentChart.Height - Shape.Height - 10;
    if (Annotation2OldVal=-1) or (Top<>Annotation2OldVal) then
    begin
      Annotation2OldVal:=Top;
      Chart2.Draw;
    end;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bert B.
Newbie
Newbie
Posts: 69
Joined: Fri Jun 15, 2007 12:00 am

Re: Annotation Tool drawing problem

Post by Bert B. » Wed Nov 09, 2011 12:14 pm

Hello Yeray,

Thanks for the workaround. I suppose that this will get fixed in an official release eventually?

Regards,
Bert

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Annotation Tool drawing problem

Post by Yeray » Wed Nov 09, 2011 2:22 pm

Hello Bert,

I don't think we can consider it as a bug, but a per design behaviour.
Note that, when the code in your AfterDraw event is executed, the chart is already drawn and so is the annotation. So, changing the position of an element that has already been drawn, the new element position will logically be applied in the next repaint.
I'm not sure if my explanation has been clarifying... :oops: Don't hesitate to ask for another one if you get confused! :)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bert B.
Newbie
Newbie
Posts: 69
Joined: Fri Jun 15, 2007 12:00 am

Re: Annotation Tool drawing problem

Post by Bert B. » Wed Nov 09, 2011 2:38 pm

Hello Yeray,

I understand your explanation.

In TeeChart there are several options to place the annotation tool.
sshot-4.png
sshot-4.png (4.2 KiB) Viewed 7617 times
And we have the choice for a custom position.
sshot-5.png
sshot-5.png (4.1 KiB) Viewed 7621 times
In my situation I want the annotation in the bottom left corner, but not exactly in the position it is placed by TeeChart.
It would be cool if TeeChart would treat the custom values as offsets regarding to the chosen position. This would remove the need for my OnAfterDraw code.

Regards,
Bert

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Annotation Tool drawing problem

Post by Yeray » Thu Nov 10, 2011 3:20 pm

Hello Bert,
Bert B. wrote:It would be cool if TeeChart would treat the custom values as offsets regarding to the chosen position. This would remove the need for my OnAfterDraw code.
This would affect other customers who already are using the actual absolute custom coordinates. But we could add a property, for example named useRelativeCoords, that would be false by default. And setting it to true the Top and Left positions would count from the Auto alignment position set.
I've added it to the wish list to be implemented in future releases (TV52015825)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply