Marks Placement when using mouse wheel

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Errol
Newbie
Newbie
Posts: 35
Joined: Mon Jul 02, 2018 12:00 am

Marks Placement when using mouse wheel

Post by Errol » Mon Aug 20, 2018 6:17 am

Good evening

I use stacked bar charts to represent a geological column. Besides each section (strata) I place a comment using the code below:

Code: Select all

procedure TPBQuickGraph.PlaceComments;
var
  s, i, tmpSize, LIndex, LMarksHeight : integer;
  LComment: string;

begin
  Chart.Draw;
  LIndex := 0; // legend included so need to pick 2, 4, etc (0 = legend)
  for s := 1 to fIntervalQueryCollection.SeriesListB.Count - 1 do
    if (s mod 2 = LIndex) then // every second series in SeriesListB
      with TUnitBarSeries(fIntervalQueryCollection.SeriesListB.Objects[s]) do
      begin
        fIntervalQueryCollection.IntervalQuery.First;
        for i := 0 to TUnitBarSeries(fIntervalQueryCollection.SeriesListB.Objects[s]).Count - 1 do
        begin
          LComment := fIntervalQueryCollection.IntervalQuery.FieldByName('Strata Comment').AsString;
          with Marks.Positions[i] do
          begin
            if (Labels[i] <> '') then
            begin
              Custom := true;
              LeftTop.X := CalcXPos(0) + fBarWidth + fCommentStart;
              tmpSize := CalcYSizeValue(YValue[i]);
              LMarksHeight := Marks.Height;
              LeftTop.Y := CalcYPos(i) - (tmpSize div 2) - (LMarksHeight div 2);
            end
            else
              Marks.Item[i].Text.Text := '';
          end;
          fIntervalQueryCollection.IntervalQuery.Next;
        end;
      end;
end;
This places the comments correctly when first displaying the graph and when called after the OnZoom, OnUndoZoom and OnScroll events. However, calling PlaceComments in the OnMouseWheel event misplaces the marks up or down as shown in the following figures.
The attachment Comment_Location.png is no longer available
The attachment Comment_Location_Down.png is no longer available
Comment_Location.png
Correct position of comments
Comment_Location.png (2.51 KiB) Viewed 12456 times
I would be grateful if you can suggest how I might fix this.
Best regards
Errol

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

Re: Marks Placement when using mouse wheel

Post by Yeray » Wed Aug 22, 2018 6:37 am

Hello,

Maybe you need to force another repaint (Chart1.Draw) at the end of this method.
I can't see all the images, could you please edit your opening post or reply adding them?
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

Errol
Newbie
Newbie
Posts: 35
Joined: Mon Jul 02, 2018 12:00 am

Re: Marks Placement when using mouse wheel

Post by Errol » Thu Aug 23, 2018 4:43 am

Good afternoon
Thanks for your suggestions. I have tried calling Chart.Draw at various places - in PlaceComments and in OnMouseWheel, to no avail.
I have attached the images again. I hope they get through this time.
The attachment Comment_Correct_Location.png is no longer available
The attachment Comment_Location_MouseWheelDown.png is no longer available
Comment_Correct_Location.png
Correct comment location
Comment_Correct_Location.png (4 KiB) Viewed 12448 times

Errol
Newbie
Newbie
Posts: 35
Joined: Mon Jul 02, 2018 12:00 am

Re: Marks Placement when using mouse wheel

Post by Errol » Thu Aug 23, 2018 4:46 am

I seem unable to attach the three images so I have attached images 2 and 3 here.
The attachment Comment_Location_MouseWheelDown.png is no longer available
Comment_Location_MouseWheelDown.png
Comment location after mouse wheel down
Comment_Location_MouseWheelDown.png (4.39 KiB) Viewed 12448 times

Errol
Newbie
Newbie
Posts: 35
Joined: Mon Jul 02, 2018 12:00 am

Re: Marks Placement when using mouse wheel

Post by Errol » Thu Aug 23, 2018 4:48 am

And here is the final image. Each time, Preview shows the three images correctly, but when I submit the post, the attachments vanish
Attachments
Comment_Location_MouseWheelUp.png
Comment location after mouse wheel up
Comment_Location_MouseWheelUp.png (4.02 KiB) Viewed 12448 times

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

Re: Marks Placement when using mouse wheel

Post by Yeray » Thu Aug 23, 2018 8:46 am

Hello Errol,

I'm sorry for the problems attaching images. There seems to be a bug in phpbb 3.2.2 (reference here). I've applied the fix and it seems to be working now.

Regarding the problem with the marks, note the OnMouseWheel event is fired before applying the axis scroll. That's why your PlaceComments method doesn't calculate the positions properly. You can set a flag at OnMouseWheel and call PlaceComments at OnAfterDraw event when that flag is set. Here a simple example:
testMarks.zip
(83.23 KiB) Downloaded 699 times
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

Errol
Newbie
Newbie
Posts: 35
Joined: Mon Jul 02, 2018 12:00 am

Re: Marks Placement when using mouse wheel

Post by Errol » Fri Aug 31, 2018 2:12 pm

Good evening
Thank you for your assistance here. I have implemented your suggestions and it works fine now. Obvious really, once one knows how to do it, but I find the TeeChart events a bit daunting at times.
Best regards
Errol

Post Reply