TColorLineTool only visible within ColorBand range

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Charles
Newbie
Newbie
Posts: 3
Joined: Tue Jan 29, 2013 12:00 am

TColorLineTool only visible within ColorBand range

Post by Charles » Tue Jan 29, 2013 6:17 pm

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 4748 times
Thanks in advance for your help,


Charles

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

Re: TColorLineTool only visible within ColorBand range

Post by Yeray » Thu Jan 31, 2013 4:12 pm

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;
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

Charles
Newbie
Newbie
Posts: 3
Joined: Tue Jan 29, 2013 12:00 am

Re: TColorLineTool only visible within ColorBand range

Post by Charles » Thu Jan 31, 2013 6:12 pm

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

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

Re: TColorLineTool only visible within ColorBand range

Post by Yeray » Fri Feb 01, 2013 8:41 am

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.
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

Charles
Newbie
Newbie
Posts: 3
Joined: Tue Jan 29, 2013 12:00 am

Re: TColorLineTool only visible within ColorBand range

Post by Charles » Mon Feb 04, 2013 5:25 pm

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

Post Reply