Page 1 of 1

CursorTool

Posted: Tue Jan 18, 2011 2:42 pm
by 8577919
Hi,
is it possible to realize something like an "open curtain" with the cursortool (or anything else).

With two cursortools I select the area of interest the remaining areas of the chart are grayed (but transparent).

Please, see the picture to get my intention.

Moreover, it would be great to be able to move the area of interest with one mousemove.

Regards,
Josef

Re: CursorTool

Posted: Wed Jan 19, 2011 1:17 pm
by yeray
Hi Josef,

You could use a TColorBandTool and change its StartValue and EndValue at OnMouseMove event.
Here it is a simple example:

Code: Select all

uses Series, TeeTools;

var ColorBand1: TColorBandTool;
    rectWidth: Integer; //pixels

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  with ColorBand1 do
  begin
    StartValue:=Chart1.Axes.Bottom.CalcPosPoint(Round(X-rectWidth/2));
    EndValue:=Chart1.Axes.Bottom.CalcPosPoint(Round(X+rectWidth/2));
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  rectWidth:=50;

  with Chart1.AddSeries(TLineSeries) do FillSampleValues();

  ColorBand1:=Chart1.Tools.Add(TColorBandTool) as TColorBandTool;
  with ColorBand1 do
  begin
    Axis:=Chart1.Axes.Bottom;
  end;
end;