Callout - wrong position after Tee loading

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Callout - wrong position after Tee loading

Post by moelski » Sat Feb 23, 2008 2:31 pm

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?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Feb 25, 2008 11:41 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Tue Mar 04, 2008 3:20 pm

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 ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 04, 2008 3:25 pm

Hi Dominik,

Do you call this code after resizing the chart as well?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Tue Mar 04, 2008 3:28 pm

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 04, 2008 3:30 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Thu Mar 20, 2008 11:05 am

Hi Narcis,

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

Post Reply