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
Resizing / Moving an Axis
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.
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
http://www.steema.com
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