How to connect chart and real image co-ordinates ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Juri
Newbie
Newbie
Posts: 4
Joined: Fri Nov 15, 2002 12:00 am
Location: Russia
Contact:

How to connect chart and real image co-ordinates ?

Post by Juri » Tue Dec 23, 2003 10:41 am

Hello,
I am using TContourSeries for GIS system.
I am adding a TChartImageTool on my chart .Image is the map and map have real base co-ordinates. Default chart assign to image co-ordinates Axis.Maximum and Axis.Minimum. How to connect chart and real image co-ordinates ?

Thank you

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Dec 30, 2003 9:35 pm

Hi, Juri
Default chart assign to image co-ordinates Axis.Maximum and Axis.Minimum
True, if image tool is not connected to series. Otherwise the series minimum and maximum x and y values are being used. This is all done in TChartImageTool.ChartEvent method. To customize this (be able to define image position and width/height, expressed in real values), you should override and change this method implementation.

Or alternatively, you can simply draw image directly on chart Canvas in TChart.OnBeforeDrawSeries event (or other even, depending if you want image behind or in front of series). The following code should give you an idea:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.LeftAxis.SetMinMax(0,10);
  Chart1.BottomAxis.SetMinMax(0,10);
end;

procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
var R: TRect;
begin
  With Chart1.Canvas do
  begin
    R.Bottom := Chart1.LeftAxis.CalcYPosValue(5.5);
    R.Top := Chart1.LeftAxis.CalcYPosValue(15.5);
    R.Left:= Chart1.BottomAxis.CalcXPosValue(3.5);
    R.Right:= Chart1.BottomAxis.CalcXPosValue(12.5);
    ClipRectangle(Chart1.ChartRect);
    StretchDraw(R,Image1.Picture.Graphic);
    UnclipRectangle;
  end;
end;
Marjan Slatinek,
http://www.steema.com

Post Reply