Page 1 of 1

TColorLineTool only visible within ColorBand range

Posted: Tue Jan 29, 2013 6:17 pm
by 16564856
Hi,
Is there a way to have a TColorLineTool only visible when it intersects a ColorBand?

If you look at the attached image, I would like the orange line to be only visible within the gray area (ColorBand).
Chart.png
Chart
Chart.png (13.18 KiB) Viewed 4752 times
Thanks in advance for your help,


Charles

Re: TColorLineTool only visible within ColorBand range

Posted: Thu Jan 31, 2013 4:12 pm
by yeray
Hi Charles,

The easiest solution would be to draw the horizontal line manually. Ie:

Code: Select all

uses Series, TeeTools, TeCanvas;

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

  Chart1.AddSeries(TFastLineSeries).FillSampleValues;

  with Chart1.Tools.Add(TColorBandTool) as TColorBandTool do
  begin
    Axis:=Chart1.Axes.Bottom;
    StartValue:=10;
    EndValue:=15;
    Transparency:=50;
    Color:=clGray;
  end;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var StartX, EndX, PosY: Integer;
begin
  with Chart1[0].YValues do
    PosY:=Chart1.Axes.Left.CalcPosValue(MinValue + (MaxValue-MinValue)*2/3);

  with Chart1.Axes.Bottom, (Chart1.Tools[0] as TColorBandTool) do
  begin
    StartX:=CalcPosValue(StartValue);
    EndX:=CalcPosValue(EndValue);
  end;

  with Chart1.Canvas do
  begin
    Pen.Color:=clRed;
    Line(StartX, PosY, EndX, PosY);
  end;
end;

Re: TColorLineTool only visible within ColorBand range

Posted: Thu Jan 31, 2013 6:12 pm
by 16564856
Hi Yeray,
thank you for your reply. But I still need to be able to drag up or down that line. This line represent a user adjustable setting.

Is there any way I could do that?


Regards

Charles

Re: TColorLineTool only visible within ColorBand range

Posted: Fri Feb 01, 2013 8:41 am
by yeray
Hi Charles,

I'll add to the wish list the possibility to set a minimum and a maximum for the TColorLineTool (TV52016498).
In the meanwhile, I see two options:
- Improve the example above to add the features you require. You could use OnMouseMove event to change the Cursor to crVSplit when the mouse is over the line; and you could use the OnMouseDown, OnMouseUp and OnMouseMove events to implement the dragging feature.
- If you are SourceCode customer (I believe you are), you could modify the TColorLineTool to behave as you want. I guess with some modifications at the TColorLineTool.DrawColorLine method from TeeTools.pas would be enough for you.

Re: TColorLineTool only visible within ColorBand range

Posted: Mon Feb 04, 2013 5:25 pm
by 16564856
Hi Yeray,
thank you for your suggestions, I will do that while waiting for an update that supports Min ans Max on a TcolorLineTool


Regards

Charles