Page 1 of 1

How to connect chart and real image co-ordinates ?

Posted: Tue Dec 23, 2003 10:41 am
by 5894817
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

Posted: Tue Dec 30, 2003 9:35 pm
by Marjan
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;