Page 1 of 1

Callout - wrong position after Tee loading

Posted: Sat Feb 23, 2008 2:31 pm
by 9349911
Hi !

We use Tannotaiotn with Callouts to mark positions in the chart. Works ok so far.

But if you save the chart to a tee file, resize the application (and the chart) and load the tee file back the callout x/y value is wrong.

The X / Y values of the callout are stored as pixel values. And they are used after loading the tee to set the callout position. But if you resize the chart before loading the tee it ends up with a wrong position.

What can I do to fix this?

Posted: Mon Feb 25, 2008 11:41 am
by narcis
Hi Dominik,

Yes, even though your code sets relative positions they are saved in pixels. So you should run the code for positioning annotation and its callout after loading the .tee file.

Posted: Tue Mar 04, 2008 3:20 pm
by 9349911
Hi Narcis,
So you should run the code for positioning annotation and its callout after loading the .tee file
I do this. But there is one problem left. This only works if you chart doesn´t resize.

So lets say you have a chart size from 800*600. You place a callout at position x200 y250. Then you store it within a tee file.
Now you close your application, restart it and resize the form. Letzs say your chart is now 600 * 400 only. Now load the tee file and the callout has the wrong position. It stays at position 200 / 250.

But it must be at the following position:
200 / (800 / 600) = 150
250 / (600 / 400) = 166,67

I use this code for setting the callouts. But it wont work after resizing the chart:

Code: Select all

procedure TForm1.SetAnnoPos;
var I       : Integer;
    _Count  : Integer;
begin
  MainChart.Draw;
  _Count := 0;
  for i := 0 to MainChart.Tools.Count - 1 do begin
    if ((MainChart.Tools[i]     is TRectangleTool)  and
        (MainChart.Tools[i].Tag > 19999)            and
        (MainChart.Tools[i].Tag < 30000)            and
        (Length(AnnoPos) > 0))                      then begin
      Inc(_Count);
      TRectangleTool(MainChart.Tools[i]).Left := MainChart.Axes.Bottom.CalcXPosValue(AnnoPos[_Count - 1].ToolPosX);
      TRectangleTool(MainChart.Tools[i]).Top  := MainChart.CustomAxes[0].CalcYPosValue(AnnoPos[_Count - 1].ToolposY);
      if TRectangleTool(MainChart.Tools[i]).Callout.Visible = True then begin
        TRectangleTool(MainChart.Tools[i]).Callout.XPosition := MainChart.Series[0].CalcXPosValue(AnnoPos[_Count - 1].ArrowPosX);
        TRectangleTool(MainChart.Tools[i]).Callout.YPosition := MainChart.Series[0].CalcYPosValue(AnnoPos[_Count - 1].ArrowPosY);   // Series1
      end;
    end;
  end;
end;
Any idea what I can do ?

Posted: Tue Mar 04, 2008 3:25 pm
by narcis
Hi Dominik,

Do you call this code after resizing the chart as well?

Posted: Tue Mar 04, 2008 3:28 pm
by 9349911
Hi Narcis,
procedure TForm1.MainChartResize(Sender: TObject);
begin
// Marker neu positionieren
SetAnnoPos;
end;
Yes :)

But that´s not the problem. Normal resizing works great if the callout is visible in the chart.
You only get a problem if you clear the chart, resize the form/chart and reload the tee file with the annotaion.

The old chart size should be calculated as shown above. This would fix the problem. But I have no idea how to do this.

Posted: Tue Mar 04, 2008 3:30 pm
by narcis
Hi Dominik,

In that case you should run that code after loading the .tee file. If the problem persists please send us a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.

Posted: Thu Mar 20, 2008 11:05 am
by 9349911
Hi Narcis,

I´ve posted all information here:
http://www.teechart.net/support/viewtopic.php?t=7502