TColorBandTool limits

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PoLabs
Newbie
Newbie
Posts: 17
Joined: Mon Sep 01, 2014 12:00 am

TColorBandTool limits

Post by PoLabs » Wed Jan 07, 2015 11:29 am

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
Attachments
selector.jpg
selector.jpg (29.4 KiB) Viewed 7959 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TColorBandTool limits

Post by Yeray » Thu Jan 08, 2015 3:22 pm

Hello,

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,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

PoLabs
Newbie
Newbie
Posts: 17
Joined: Mon Sep 01, 2014 12:00 am

Re: TColorBandTool limits

Post by PoLabs » Fri Jan 09, 2015 7:50 am

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TColorBandTool limits

Post by Yeray » Mon Jan 12, 2015 8:25 am

Hi Aljosa,

I'm glad to hear it helped you! :)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply