Page 1 of 1

Scroll on Selected Custom Vertical axis only

Posted: Thu Oct 02, 2008 2:16 am
by 9342039
I have 1 chart with several custom vertical axis.
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;
* On Allow Scroll event if the chart axis's index = ScrollIdx then allow the scroll.

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;
This worked but it is not elegant at all.
Is there any better way?

Thank you in advance.

Posted: Thu Oct 02, 2008 8:18 am
by narcis
Hi ChainSmokinCoder,

You could try doing as shown in the All Features\Welcome!\Axes\Scrolling multiple example at the new features demo, available at TeeChart's program group.

Hope this helps!