Page 1 of 1

Sticky Annotations

Posted: Tue Oct 23, 2007 5:12 am
by 9243548
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

Posted: Tue Oct 23, 2007 8:07 am
by narcis
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.

Sticky Annotations

Posted: Tue Oct 23, 2007 5:32 pm
by 9232023
I think I already tried that and if I rememer correctly, there were some problems. I will look again.

thanks,
kev

Posted: Tue Oct 23, 2007 5:45 pm
by 9232023
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

Posted: Wed Oct 24, 2007 8:13 am
by narcis
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!