Scroll on Selected Custom Vertical axis only

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ChainSmokinCoder
Newbie
Newbie
Posts: 12
Joined: Wed Jun 01, 2005 4:00 am
Location: wellington
Contact:

Scroll on Selected Custom Vertical axis only

Post by ChainSmokinCoder » Thu Oct 02, 2008 2:16 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Oct 02, 2008 8:18 am

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!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply