Hi,
I am using TColorBandTool as a special data selector on my chart. It looks like a resizable yellow rectangle (start and end lines are allowed to be dragged). That rectangle can be any size now ( depends upon values StartValue, EndValue) but I would like to limit that.
My question is if it's possible to limit band width in a simple way?
Let's say I would like to limit band width to 10px (10px between StartValue and EndValue). I expect that whenever I drag one side of it, it will stop resizing when it reaches minimum size of 10px and it will continue resizing when size will be greater than that.
I hope I was clear enough. Thank you in advance.
Kind regards,
Aljosa
TColorBandTool limits
TColorBandTool limits
- Attachments
-
- selector.jpg (29.4 KiB) Viewed 7954 times
Re: TColorBandTool limits
Hello,
You could use the events to force that. Ie:
You could use the events to force that. Ie:
Code: Select all
var draggingStart, draggingEnd: boolean;
procedure TForm1.ChartTool1Resizing(Sender: TObject);
var tmp: Double;
begin
tmp:=Chart1.Axes.Bottom.CalcPosPoint(10)-Chart1.Axes.Bottom.CalcPosPoint(0);
if (Chart1.Axes.Bottom.CalcSizeValue(ChartTool1.StartValue, ChartTool1.EndValue) > 10) then
begin
if draggingStart then
ChartTool1.StartValue:=ChartTool1.EndValue-tmp;
if draggingEnd then
ChartTool1.EndValue:=ChartTool1.StartValue+tmp;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
draggingStart:=false;
draggingEnd:=false;
ChartTool1.StartLine.OnBeginDragLine:=StartLineBeginDragging;
ChartTool1.StartLine.OnEndDragLine:=StartLineEndDragging;
ChartTool1.EndLine.OnBeginDragLine:=EndLineBeginDragging;
ChartTool1.EndLine.OnEndDragLine:=EndLineEndDragging;
end;
procedure TForm1.StartLineBeginDragging(Sender: TColorLineTool);
begin
draggingStart:=true;
end;
procedure TForm1.StartLineEndDragging(Sender: TColorLineTool);
begin
draggingStart:=false;
end;
procedure TForm1.EndLineBeginDragging(Sender: TColorLineTool);
begin
draggingEnd:=true;
end;
procedure TForm1.EndLineEndDragging(Sender: TColorLineTool);
begin
draggingEnd:=false;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TColorBandTool limits
Hi,
thanks for fast response. Your solution helped me a lot. It's still not exactly what I was looking for but the idea and approach helped me to develop my solution.
Thank you again.
Aljosa
thanks for fast response. Your solution helped me a lot. It's still not exactly what I was looking for but the idea and approach helped me to develop my solution.
Thank you again.
Aljosa
Re: TColorBandTool limits
Hi Aljosa,
I'm glad to hear it helped you!
I'm glad to hear it helped you!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |