1.) Clip DragPoint to min/max.
TDragPointTool=class(TTeeCustomToolSeries)
private
fXMinimum:double;
fXMaximum:double;
fYMinimum:double;
fYMaximum:double;
fXClip:boolean;
fYClip:boolean;
....
published
property XMinimum:double read fXMinimum write fXMinimum;
property XMaximum:double read fXMaximum write fXMaximum;
property YMinimum:double read fYMinimum write fYMinimum;
property YMaximum:double read fYMaximum write fYMaximum;
property XClip:boolean read fXClip write fXClip;
property YClip:boolean read fYClip write fYClip;
Constructor TDragPointTool.Create(AOwner: TComponent);
begin
inherited;
fXMinimum:=-1000.0;
fXmaximum:=1000.0;
fYMinimum:=-1000.0;
fYmaximum:=1000.0;
fXClip:=true;
fYClip:=true;
procedure TDragPointTool.ChartMouseEvent(AEvent: TChartMouseEvent;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Function CheckAxisLimits(Axis:TChartAxis; Position:Integer):Double;
begin
with Axis do
if Maximum=Minimum then
begin
AutomaticMaximum:=False;
Maximum:=Maximum+0.1*MinAxisIncrement; // 6.02, fix when values are equal
end;
result:=Axis.CalcPosPoint(Position);
end;
var
Tmp:double;
begin
if Assigned(Series) then
Case AEvent of
cmeUp: IDragging:=-1; { stop dragging on mouse up }
cmeMove: if IDragging<>-1 then { if dragging... }
With Series do
begin
BeginUpdate;
{ Change the Series point X and / or Y values... }
if (Self.DragStyle=dsX) or (Self.DragStyle=dsBoth) then
begin
Tmp:=XScreenToValue(x);
if Tmp < fXMinimum then
Tmp := fXMinimum;
if Tmp > fXMaximum then
Tmp := fXMaximum;
if fXClip=true then
begin
if (IDragging = 0) and (IDragging < (count-1)) then // 1.Pkt
begin
if Tmp > XValue[IDragging+1] then
Tmp:= XValue[IDragging+1];
end else
begin
if IDragging = (count-1) then // last Pkt
begin
if (IDragging > 0) and (Tmp < XValue[IDragging-1]) then
Tmp:= XValue[IDragging-1];
end else
begin
if Tmp > XValue[IDragging+1] then
Tmp:= XValue[IDragging+1];
if Tmp < XValue[IDragging-1] then
Tmp:= XValue[IDragging-1];
end;
end;
XValue[IDragging]:=Tmp;
end else
begin
XValue[IDragging]:=CheckAxisLimits(GetHorizAxis,x);
end;
end;
if (Self.DragStyle=dsY) or (Self.DragStyle=dsBoth) then
begin
if fYClip=true then
begin
Tmp:=YScreenToValue(y);
if Tmp < fYMinimum then
Tmp := fYMinimum;
if Tmp > fYMaximum then
Tmp := fYMaximum;
YValue[IDragging]:=Tmp;
end else
begin
YValue[IDragging]:=CheckAxisLimits(GetVertAxis,y);
end;
end;
EndUpdate;
{ Notify the point values change... }
if Assigned(FOnDrag) then FOnDrag(Self,IDragging);
end;
cmeDown: begin { when the mouse button is pressed... }
IDragging:=Series.Clicked(x,y);
{ if clicked a Series point... }
if IDragging<>-1 then ParentChart.CancelMouse:=True;
end;
end;
end;
2.) disable Mousewheel function if no panning
function TCustomChart.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
{$IFDEF CLX}const{$ENDIF} MousePos: TPoint): Boolean;
begin
result:=false; // <---- here
if AllowPanning <> pmNone then // <--- and here
result:=inherited DoMouseWheel(Shift,WheelDelta,MousePos);
Please insert following Sourcecode
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Achim,
Sorry but I don't understand which are the exact problems here. Could you please provide more detailed information?
Thanks in advance.
Sorry but I don't understand which are the exact problems here. Could you please provide more detailed information?
Thanks in advance.
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 |
1.)
Sorry but I don't understand which are the exact problems here. Could you please provide more detailed information?
Thanks in advance.
If you use the mouse to drag a series point, there is no limit. You can drag and drag and drag, the values can grows up to thousand and millions.
With the code above, it is possible to clip/limit this behavour. You can set a min/max value, and if you want to drag beyond these values, the dragging will stop.
2.)
It is(or was in older versions) possible to use the mouse wheel for panning, even if panning is not allowed. The two lines prevent this behaviour.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Achim,
Thanks for your suggestion. We'll add your suggestion to the wish-list to be considered for inclusion in future releases. However, some users may not be happy with this change as it may break their functionality.1.)
If you use the mouse to drag a series point, there is no limit. You can drag and drag and drag, the values can grows up to thousand and millions.
With the code above, it is possible to clip/limit this behavour. You can set a min/max value, and if you want to drag beyond these values, the dragging will stop.
You can achieve this much easily. You just need to use this:2.)
It is(or was in older versions) possible to use the mouse wheel for panning, even if panning is not allowed. The two lines prevent this behaviour.
Code: Select all
TeeUseMouseWheel := True;
Chart1.TabStop:=True;
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 |
There is an on/off property in the code above. Default-seting should be 'off'.However, some users may not be happy with this change as it may break their functionality.
You can achieve this much easily. You just need to use this:2.)
It is(or was in older versions) possible to use the mouse wheel for panning, even if panning is not allowed. The two lines prevent this behaviour.
Code: Select all
TeeUseMouseWheel := True;
Chart1.TabStop:=True;
Thanks, I'll try it.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Achim,
Ok, thanks for your feedback!
Ok, thanks for your feedback!
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 |