Sticky Annotations

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Kev
Newbie
Newbie
Posts: 7
Joined: Wed Jan 03, 2007 12:00 am

Sticky Annotations

Post by Kev » Tue Oct 23, 2007 5:12 am

How can I make Annotation Tools stick to a specific spot on the chart without having to tie them to a series data point using "Nearest"? I have done this already and the Anno tools move accordingly, as they should, when the chart is zoomed, panned or rescaled. However, the user wants to place the annotations at known y-axis positions prior to loading any data. I sort of made a work around where I just add a non visible series pre-populated with a lot of data ("0's). It sort of works, but I would rather not have to tie up a series for that.

Is there a way for me to tie a Annotation to the Left Axis instead of a series point?

thanks,
Kev

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Oct 23, 2007 8:07 am

Hi Kev,

In that case you could manually set axes minimum and maximum values using SetMinMax method, then internally paint the chart doing a Chart1.Draw call and then you can place the marks at known axis positions using Chart1.Axes.Left.CalcPosValue method.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

kev
Newbie
Newbie
Posts: 42
Joined: Tue Apr 06, 2004 4:00 am
Location: Texas

Sticky Annotations

Post by kev » Tue Oct 23, 2007 5:32 pm

I think I already tried that and if I rememer correctly, there were some problems. I will look again.

thanks,
kev

kev
Newbie
Newbie
Posts: 42
Joined: Tue Apr 06, 2004 4:00 am
Location: Texas

Post by kev » Tue Oct 23, 2007 5:45 pm

Ok,

I was using PosPoint before. I am starting to see how this might be done. What I need now is a way to convert the current Annotation position (or Mouse position) to the correct y scale value. Currently I can grab the Annotation and move it around with the mouse and then anchor it with another click. At that point in time, I want to be able to convert the current mouse position to (X,Y) into a y scale value to pass to the CalcPosValue method. Is this possible?

thanks,
Kev

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Oct 24, 2007 8:13 am

Hi Kev,

Yes, this is possible. You need to do something like the code below. This converts screen coordinates to axes values and to screen coordinates again.

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  With Chart1 do
  begin
    Title.Text.Clear;
    Title.Text.Add(IntToStr(Axes.Bottom.CalcXPosValue(Axes.Bottom.CalcPosPoint(X))));
    Title.Text.Add(IntToStr(Axes.Left.CalcYPosValue(Axes.Left.CalcPosPoint(Y))));
  end;
end;
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply