Page 1 of 1

Annotation Tool drawing problem

Posted: Tue Nov 08, 2011 9:09 am
by 9350556
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 7695 times
sshot-3.png
sshot-3.png (33.85 KiB) Viewed 7694 times
Regards,
Bert

Re: Annotation Tool drawing problem

Posted: Wed Nov 09, 2011 9:57 am
by yeray
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;

Re: Annotation Tool drawing problem

Posted: Wed Nov 09, 2011 12:14 pm
by 9350556
Hello Yeray,

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

Regards,
Bert

Re: Annotation Tool drawing problem

Posted: Wed Nov 09, 2011 2:22 pm
by yeray
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! :)

Re: Annotation Tool drawing problem

Posted: Wed Nov 09, 2011 2:38 pm
by 9350556
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 7621 times
And we have the choice for a custom position.
sshot-5.png
sshot-5.png (4.1 KiB) Viewed 7625 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

Re: Annotation Tool drawing problem

Posted: Thu Nov 10, 2011 3:20 pm
by yeray
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)