There are two mousewheel zoom modes depending on the selection of to property "FixedPoint" of the MouseWheelZoomTool (
http://wiki.lazarus.freepascal.org/TAChart_documentation#Extent_tools):
- FixedPoint = true --> zooming uses the current mouse position as a stationary point
- FixedPoint = false --> zooming uses the center of the visible chart window as a stationary point (This mode was not working correctly, I fixed it in r51858 of trunk and requested backporting to Laz 1.6 RC3)
Is FixedPoint = false ok for you? Or do you really need to zoom relative to the origin?
[EDIT]
If you really want to zoom relative to the origin you can add a TZoomMouseWheelTool, set its FixedPoint to false and ZoomFactor to a value slightly larger than 1 (maybe 1.1). Then add event handlers for OnBeforeMouseWheelUp and OnBeforeMouseWheelDown and the following code:
uses
TAChartUtils, TAGeometry;
{ TForm1 }
procedure TForm1.DoZoomStep(ATool: TChartTool; const AFactor: TDoublePoint);
var
sz, center: TDoublePoint;
ext: TDoubleRect;
begin
ext := Chart1.LogicalExtent;
sz := ext.b - ext.a;
center := DoublePoint(ext.a.x, ext.a.y);
ext.a := center;
ext.b := center + sz * AFactor;
Chart1.LogicalExtent := ext;
end;
procedure TForm1.ChartToolset1ZoomMouseWheelTool2BeforeMouseWheelDown(
ATool: TChartTool; APoint: TPoint);
var
tool: TZoomMouseWheelTool;
begin
tool := TZoomMouseWheelTool(ATool);
if (tool.ZoomFactor > 0) and (tool.ZoomRatio > 0) then
DoZoomStep(ATool, DoublePoint(
tool.ZoomFactor,
tool.ZoomFactor * tool.ZoomRatio)
);
ATool.Handled;
end;
procedure TForm1.ChartToolset1ZoomMouseWheelTool2BeforeMouseWheelUp(
ATool: TChartTool; APoint: TPoint);
var
tool: TZoomMouseWheelTool;
begin
tool := TZoomMouseWheelTool(ATool);
if (tool.ZoomFactor > 0) and (tool.ZoomRatio > 0) then
DoZoomStep(ATool, DoublePoint(
1 / tool.ZoomFactor,
1 / tool.ZoomFactor / tool.ZoomRatio)
);
ATool.Handled;
end;
The DoZoomStep procedure (which is adapted from the original code of the tool) sets the zoom origin at the lower left corner of the chart window (Chart.Logicalextent.a) and, from here, multiplies to Chart.Logicalextent by the zoom factor.
It would be a good exercise for you to modify this procedure such that zooming is relative to any other point