Page 1 of 1

TColorLineTool with label

Posted: Thu Apr 19, 2012 4:33 am
by 9341927
Hi,

I would like to do something like in the picture.

Image

From my research, it uses TColorLineTool. But I don't know how to add a label on the hori line. The label holds the value of left axis value point. You can move the hori line. You can also type the value in the label and the line moves to that value.

Is that builtin feature from TeeChar pro 2012?
How do i implement it?

Regards,

Re: TColorLineTool with label

Posted: Thu Apr 19, 2012 11:34 am
by narcis
Hi Matt,

You can use a TColorLineTool in synch with a TAnnotationTool as shown in the attached project. You could also do custom text drawing directly to TeeChart's canvas in the OnAfterDraw event, for example.

Hope this helps!

Re: TColorLineTool with label

Posted: Thu Apr 19, 2012 2:33 pm
by narcis
Hello,

Sorry, I forgot to answer that part:
You can also type the value in the label and the line moves to that value.
Currently there's no built-in functionality to do that. Rectangle tool, similar to Annotation tool, supports editing with TeeChart for .NET. I have added this (TV52016160) to the wish-list to be considered for inclusion in future releases. In the meantime, the only option I can think of is using a TEdit which modifies both the ColorLine.Value and Annotation.Text. You could make that TEdit only visible when clicking in the Annotation tool using the OnClick or OnDblClick events. You could also position it in the Annotation tool position. I already showed you how to get and set its position.

Re: TColorLineTool with label

Posted: Fri Apr 20, 2012 4:54 am
by 9341927
Narcís wrote:Hi Matt,

You can use a TColorLineTool in synch with a TAnnotationTool as shown in the attached project. You could also do custom text drawing directly to TeeChart's canvas in the OnAfterDraw event, for example.

Hope this helps!
Hi Narcis,
The example is perfectly working and great one. But if you zoom-in the graph, the annotation is still hanging on the same place. I tired to work around to get proper position of annotation. But I don't know how to get Top and Left of annotation.

Do you know how to set the annotation on the TColorLineTool when you zoom-in.
Narcís wrote:Hello,
Currently there's no built-in functionality to do that. Rectangle tool, similar to Annotation tool, supports editing with TeeChart for .NET. I have added this (TV52016160) to the wish-list to be considered for inclusion in future releases. In the meantime, the only option I can think of is using a TEdit which modifies both the ColorLine.Value and Annotation.Text. You could make that TEdit only visible when clicking in the Annotation tool using the OnClick or OnDblClick events. You could also position it in the Annotation tool position. I already showed you how to get and set its position.
Thanks for advice and explanation. Thanks again

Regards

Re: TColorLineTool with label

Posted: Mon Apr 23, 2012 8:36 am
by yeray
Hi,
Matt Venkat wrote:The example is perfectly working and great one. But if you zoom-in the graph, the annotation is still hanging on the same place. I tired to work around to get proper position of annotation. But I don't know how to get Top and Left of annotation.
To update the annotation position afterzooming/unzooming/scrolling you should use the according event to move it as Narcís did in the example above. For example, you could enhance it with this:

Code: Select all

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  Chart1.Draw;
  UpdateAnnotationPosition(ChartTool1.Value, ChartTool2);
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  Chart1.Draw;
  UpdateAnnotationPosition(ChartTool1.Value, ChartTool2);
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  UpdateAnnotationPosition(ChartTool1.Value, ChartTool2);
end;

Re: TColorLineTool with label

Posted: Tue Apr 24, 2012 7:17 am
by 9341927
Yeray wrote:Hi,
To update the annotation position afterzooming/unzooming/scrolling you should use the according event to move it as Narcís did in the example above. For example, you could enhance it with this:

Code: Select all

  Chart1.Draw;
Thank alot Yeray. It works fine now.
Chart1.Draw fixes the problem.

Thanks again.

Cheers