Each axis has different StartPosition and EndPosition so they look stacked on top of each other.
(example :
CustomAxes[0].StartPosition := 0;
CustomAxes[0].EndPosition := 49;
CustomAxes[1].StartPosition := 51;
CustomAxes[1].EndPostion := 100; )
The problem is whenever I scroll vertically, both axes would scroll.
I only want to scroll the one that was clicked within the axis.
My solution is :
* To get the index of the custom axis where the mouse down event occured and store it into ScrollIdx var.
Code: Select all
procedure TDAQfrm.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
This : TChart;
YPerc : double;
i : integer;
begin
This := (Sender as TChart);
Yperc := (Y / This.Height) * 100;
for i := 0 to This.CustomAxes.Count -1 do
with This.CustomAxes[i] do
begin
if This.CustomAxes[i].Visible then
if (This.CustomAxes[i].StartPosition <= YPerc) and (This.CustomAxes[i].EndPosition >= YPerc) then
ScrollIdx := i;
end;
end;
Code: Select all
procedure TDAQfrm.Chart1AllowScroll(Sender: TChartAxis; var AMin,
AMax: Double; var AllowScroll: Boolean);
begin
if Sender.Index <> ScrollIdx then
AllowScroll := false
else
AllowScroll := true;
end;
Is there any better way?
Thank you in advance.