Page 1 of 1

Problem with placing a TImage on top of TeeChart

Posted: Wed Jul 20, 2005 2:20 pm
by 9231359
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

Posted: Wed Jul 20, 2005 3:06 pm
by narcis
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.

Posted: Wed Jul 20, 2005 3:25 pm
by 9231359
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.

Posted: Thu Jul 21, 2005 7:30 am
by narcis
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.