Problem with placing a TImage on top of TeeChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bc2m
Newbie
Newbie
Posts: 3
Joined: Thu Mar 11, 2004 5:00 am
Location: Scotland
Contact:

Problem with placing a TImage on top of TeeChart

Post by bc2m » Wed Jul 20, 2005 2:20 pm

I'm developing a mapping system for placing students. The map is the "backImage" of the chart, and then I simply plot Eastings/Northings using a scatterplot.

However. I want to measure distances on the map. I placed a TIMage exactly on top of the TChart component, and then used the mouse events to do rubber banding.

HOWEVER, no matter what I do (e.g manually or programatically sending the TCHart to back) the TImage is ALWAYS behind the TChart, so although the rubber banding works when the TImage is not behind the TChart, obviously it doesn't when behind TChart!! :-)

Is there a fix for this problem - I simply can't see a way to "Rubber band" directly on the TChart. Is this possible? (I have tried using the TChart.canvas, but nothing appears)

Help!

Barry

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

Post by Narcís » Wed Jul 20, 2005 3:06 pm

Hi Barry,

From your post I note that you first placed the image as the backimage of the Chart (ie. Chart1.BackImage). You could trace mousemovements over that using the x and y of the TeeChart mousemove. If you require that the image completely hide Chart contents then you could alternatively plot the image to the Chart using the Canvas event OnAfterDraw:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  with Chart1.Canvas do
  begin
    Draw(0,0,Image1.Picture.Graphic);

    Pen.Color:=clRed;
    MoveTo(0,0);
    LineTo(100,100);
  end;
end;
However you have another option that would be using an Image tool, which places an image behind the series. You can find an example of ImageTool at TeeChart features demo, available at TeeChart program group. Once you have the image on the chart you could implement the "Rubber banding" drawing directly on the TChart canvas as shown in the code above. TChart has MouseDown, MouseMove and MouseUp events to implement that.
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

bc2m
Newbie
Newbie
Posts: 3
Joined: Thu Mar 11, 2004 5:00 am
Location: Scotland
Contact:

Post by bc2m » Wed Jul 20, 2005 3:25 pm

Fixed it. All you have to do is to turn off the Zoom function, then you can rubber-band directly onto the TChart!

Works a treat, and TIMage is not needed.

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

Post by Narcís » Thu Jul 21, 2005 7:30 am

Hi Barry,

I'm glad to hear you could get it working. You are right, I forgot to tell you to disable zoom or else your chart would be zoomed.
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

Post Reply