Resizing / Moving an Axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jeff
Newbie
Newbie
Posts: 2
Joined: Thu Oct 30, 2003 5:00 am

Resizing / Moving an Axis

Post by Jeff » Tue Sep 21, 2004 3:15 am

I’m working with a stock chart application where each technical indicator is on a separate horizontal axis. What I need is an easy way for the user to be able to resize each axis individually with the mouse. How can this be done? Also allowing the user to change the axis order with a drag and drop operation would be nice too.

Thanks,
Jeff

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Sep 21, 2004 3:36 pm

Hi, Jeff.

Yes, I think it can be done. You can use Chart OnMouseDown, OnMouseUp and OnMouseMove events to do this. In OnMouseDown you can check if current mouse position is over specific axis. If yes, declare that drag operation on this axis has begun. In OnMouseMove you can then (according to mouse position and dragaxis flag) change axis start or end position and in OnMouseUp define that drag operation ended. I'll try to prepare an example of this feature and include it in next maintenance release.
Marjan Slatinek,
http://www.steema.com

Jeff
Newbie
Newbie
Posts: 2
Joined: Thu Oct 30, 2003 5:00 am

Post by Jeff » Wed Sep 22, 2004 12:39 pm

I believe this code should work for resizing the axis but I am having trouble finising it. If you know the rest please let me know.

Code: Select all

//Following code goes in the ChartMouseMove event

  for i := 0 to Chart.Axes.Count - 1 do
  begin
    if (y > Chart.Axes[i].IEndPos - 3) and (y < Chart.Axes[i].IEndPos + 3) then //Allow a 6 pixel range
    begin
      Screen.Cursor := crVSplit;
      if Shift = [ssLeft] then
      begin
        Chart.Axes[i].EndPosition := // Y   <- How do I convert the Y pixel location to EndPosition Percent?
        //Chart.Axes[i + 1].StartPosition := <- How do I determine the Axis adjacent to the one I'm resizing (since ordinal position isn't necessarily layout position)
      end;
      break; //Mouse is positioned over the an axis junction
    end
    else
      Screen.Cursor := crDefault;
  end
;

Post Reply