Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-05

TAChart OnDrawReticule Event

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jorge López

I had problems with values returned by OnDrawReticule event. Always returns values from last series defined on my object.
I explore this component and I found this:

procedure TReticuleTool.MouseMove(APoint: TPoint); .
.
.

  for i := 0 to FChart.SeriesCount - 1 do
    if FChart.Series[i].GetNearestPoint(df, APoint, pointIndex, newRetPos,
value) and
      PtInRect(FChart.ClipRect, newRetPos)
    then begin
       d := df(APoint, newRetPos);
       if d < minDist then begin
         bestRetPos := newRetPos;
         bestSeries := i;
         minDist := d;
       end;
    end;
...

I think that would work something like this:

  for i := 0 to FChart.SeriesCount - 1 do
    if FChart.Series[i].GetNearestPoint(df, APoint, pointIndex, newRetPos,
value) and
      PtInRect(FChart.ClipRect, newRetPos)
    then begin
       d := df(APoint, newRetPos);
       if d < minDist then begin
         bestRetPos := newRetPos;
         bestSeries := i;
         bestPoint := pointIndex;
         bestValue := value;
         minDist := d;
       end;
    end;
  if (minDist < Infinity) and (bestRetPos  FChart.ReticulePos) then begin
    FChart.ReticulePos := bestRetPos;
    if Assigned(FChart.OnDrawReticule) then
      FChart.OnDrawReticule(FChart, bestSeries, bestPoint, bestValue);
  end;

Is that correct?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100519/55ecec10/attachment.html>

Reply by email

Alexander Klenin
to Jorge López

2010/5/20 Jorge L?pez :

I had problems with values returned by OnDrawReticule event. Always returns values from last series defined on my object. I explore this component and I found this:

[fix skipped]

Is that correct?

Yes, thanks for noticing. You are probably the first user of this event ;-) Should be fixed in r25524.

Alexander S. Klenin

Reply by email