Hi
I have a set of points plotted on a 2-D Chart with a horizontal and a vertical axis.
is it possible to disable the Right mouse drag scrolling?
Is it possible to disable the left mouse 'region' zoom?
Is it possible to disable one of the above without the other.
Also is it possible to restrict scrolling and/or zooming to be within specified bounds e.g. for horizontal scrolling I do not want to be able to scroll before the first point or after the last point. For vertical scrolling I do not want to scrol past the highest value point, but I would like to be able to scroll down no further than the lowest value point or the origin (whichever is the smaller), but no lower. Similar for when I zoom, by whatever method of zooming that is employed.
I tried code such as axis.minimum := max (axis.minimum,first point x coordinate) but although this disallowed scrolling before the first point, if I dragged with the right mouse button, the chart was stretched instead, rather than scrolled, which was not what I wanted. I wanted to be unable to scroll anymore.
I would like to be able to disable and/or restrict scrolling and or zooming independently of each other, for all methods of scrolling whether by dragging with the mouse or by using ordinary scrollbars or chartscrollbars or axisarrowtools or using delphi code or for whatever method it is possible to use to scroll. Similarly for zooming.
I would also like there to be some visual indication when the scrolling or zooming is disabled.
Sorry for all the questions in one go, but they are related.
Thanks
Colin
Disabling/restricting scrolling and zooming
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Colin,
Axes and series have several methods from converting screen coordinates to axes coordinates and series points to screen coordinates.
Yes, you can do this:is it possible to disable the Right mouse drag scrolling?
Code: Select all
Chart1.AllowPanning:=pmNone;
Yes, similar to scroll:Is it possible to disable the left mouse 'region' zoom?
Code: Select all
Chart1.AllowZoom:=false;
Yes, both settings are independent.Is it possible to disable one of the above without the other.
Yes, you could try using OnMouseMove event and something like this:Also is it possible to restrict scrolling and/or zooming to be within specified bounds e.g. for horizontal scrolling I do not want to be able to scroll before the first point or after the last point. For vertical scrolling I do not want to scrol past the highest value point, but I would like to be able to scroll down no further than the lowest value point or the origin (whichever is the smaller), but no lower. Similar for when I zoom, by whatever method of zooming that is employed.
Code: Select all
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var XVal, YVal: Double;
begin
XVal:=Chart1.Axes.Bottom.CalcPosPoint(X);
YVal:=Chart1.Axes.Left.CalcPosPoint(Y);
if ((XVal > Series1.MaxXValue) or (XVal < Series1.MinXValue)
or (YVal > Series1.MaxYValue) or (YVal < Series1.MinYValue)) then
Chart1.AllowPanning:=pmNone
else
Chart1.AllowPanning:=pmBoth;
end;
You can use any chart element and modify it according to if those features are active or not.I would also like there to be some visual indication when the scrolling or zooming is disabled.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Restricting scrolling/zooming
Many thanks for your helpful answers.
However I probably did not explain things clearly enough when I talked about restricting scrolling and/or zooming to a region.
For example if a vertical axis originally goes from 0 to 100 in values, then if a 10% zoom is made, the axis values normally then go from -10 to 110. However, I would like the vertical axis to never be less than zero, so the axis labels should be 0 and 110. However if I zoomed the other way, then it would be OK for the vertical axis to range from 10 to 90, if they originally ranged from 0 to 100.
Similarly, when scrolling, horizontally. Suppose originally the range of x coordinate values goes from 50 to 275 and the horizontal axis has a range of 100, so not all the points are shown at once. Then when I scroll horizontally, I want to scroll to the left up to the value 50 but not before 50 or to scroll up to the value 275 but not after 275. I do not want to completely disable being able to scroll when I reach these limits e.g. if I scroll left to 50, I then want to be able to scroll right all the way up to 275. When I reach 275 I then want to be able to scroll left all the way back to 50 and so on. I just want to be able to scroll horizontally between the limits of 50 and 275.
Similarly if I zoomed, rather than scrolled, I would never want to see axis labels less than 50 nor axis labels greater than 275, but I still want to be able to zoom out and zoom in, within these limits.
Regards
Colin
However I probably did not explain things clearly enough when I talked about restricting scrolling and/or zooming to a region.
For example if a vertical axis originally goes from 0 to 100 in values, then if a 10% zoom is made, the axis values normally then go from -10 to 110. However, I would like the vertical axis to never be less than zero, so the axis labels should be 0 and 110. However if I zoomed the other way, then it would be OK for the vertical axis to range from 10 to 90, if they originally ranged from 0 to 100.
Similarly, when scrolling, horizontally. Suppose originally the range of x coordinate values goes from 50 to 275 and the horizontal axis has a range of 100, so not all the points are shown at once. Then when I scroll horizontally, I want to scroll to the left up to the value 50 but not before 50 or to scroll up to the value 275 but not after 275. I do not want to completely disable being able to scroll when I reach these limits e.g. if I scroll left to 50, I then want to be able to scroll right all the way up to 275. When I reach 275 I then want to be able to scroll left all the way back to 50 and so on. I just want to be able to scroll horizontally between the limits of 50 and 275.
Similarly if I zoomed, rather than scrolled, I would never want to see axis labels less than 50 nor axis labels greater than 275, but I still want to be able to zoom out and zoom in, within these limits.
Regards
Colin
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Colin,
In that case, I'd try using OnZoom and OnScroll events for checking if axes minimum and maximum values are within series range (eg.: Series1.MinXValue and Series1.MaxXValue) and if not manually set the minimum and/or maximum to desired value.
Hope this helps!
In that case, I'd try using OnZoom and OnScroll events for checking if axes minimum and maximum values are within series range (eg.: Series1.MinXValue and Series1.MaxXValue) and if not manually set the minimum and/or maximum to desired value.
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 |
Instructions - How to post in this forum |
Hi
As I mentioned in my first email, that is precisely what I did.
However, if say I fix the left hand horizontal minimum to be the value zero, then it is OK if I then drag the mouse leftwards, because the minimum visible chart value is then greater than zero.
However, if I drag the mouse rightwards instead, then the chart streches/zooms horizontally which is not what I want. What I want in this case is for nothing to happen.
Regards
Colin
As I mentioned in my first email, that is precisely what I did.
However, if say I fix the left hand horizontal minimum to be the value zero, then it is OK if I then drag the mouse leftwards, because the minimum visible chart value is then greater than zero.
However, if I drag the mouse rightwards instead, then the chart streches/zooms horizontally which is not what I want. What I want in this case is for nothing to happen.
Regards
Colin
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Colin,
In that case you can do something like this:
In that case you can do something like this:
Code: Select all
procedure TForm1.Chart1Scroll(Sender: TObject);
var BottomRange, LeftRange: double;
begin
BottomRange:=Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum;
LeftRange:=Chart1.Axes.Left.Maximum - Chart1.Axes.Left.Minimum;
if Chart1.Axes.Bottom.Minimum < Series1.MinXValue then
Chart1.Axes.Bottom.SetMinMax(Series1.MinXValue, Series1.MinXValue + BottomRange);
if Chart1.Axes.Bottom.Maximum > Series1.MaxXValue then
Chart1.Axes.Bottom.SetMinMax(Series1.MaxXValue - BottomRange, Series1.MaxXValue);
if Chart1.Axes.Left.Minimum < Series1.MinYValue then
Chart1.Axes.Left.SetMinMax(Series1.MinYValue, Series1.MinYValue + LeftRange);
if Chart1.Axes.Left.Maximum > Series1.MaxYValue then
Chart1.Axes.Left.SetMinMax(Series1.MaxYValue - LeftRange, Series1.MaxYValue);
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi
Many thanks for that code. It worked great for scrolling.
However, I tried to use the same code, to similarly restrict zooming. However that did not work at all.
There is a difference, because zooming is usually symmetric, but when a bounding point is reached, then the zoom has to be asymmetrical.
Is there some, way to confine the zooming to be within the data point boundaries?
Thanks
Colin
Many thanks for that code. It worked great for scrolling.
However, I tried to use the same code, to similarly restrict zooming. However that did not work at all.
There is a difference, because zooming is usually symmetric, but when a bounding point is reached, then the zoom has to be asymmetrical.
Is there some, way to confine the zooming to be within the data point boundaries?
Thanks
Colin
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Colin,
For zooming you can do this:
For zooming you can do this:
Code: Select all
procedure TForm1.Chart1Zoom(Sender: TObject);
var BottomRange, LeftRange: double;
begin
BottomRange:=Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum;
LeftRange:=Chart1.Axes.Left.Maximum - Chart1.Axes.Left.Minimum;
if Chart1.Axes.Bottom.Minimum < Series1.MinXValue then
Chart1.Axes.Bottom.SetMinMax(Series1.MinXValue, Chart1.Axes.Bottom.Maximum);
if Chart1.Axes.Bottom.Maximum > Series1.MaxXValue then
Chart1.Axes.Bottom.SetMinMax(Chart1.Axes.Bottom.Minimum, Series1.MaxXValue);
if Chart1.Axes.Left.Minimum < Series1.MinYValue then
Chart1.Axes.Left.SetMinMax(Series1.MinYValue, Chart1.Axes.Left.Maximum);
if Chart1.Axes.Left.Maximum > Series1.MaxYValue then
Chart1.Axes.Left.SetMinMax(Chart1.Axes.Left.Minimum, Series1.MaxYValue);
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |