MarkText SeriesPt not scrolling Correct

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
INL2
Newbie
Newbie
Posts: 22
Joined: Mon Aug 18, 2008 12:00 am

MarkText SeriesPt not scrolling Correct

Post by INL2 » Mon Mar 09, 2015 4:15 pm

I have added some MarkText to series marks, and all works well unless the user moves the text boxes and also moves the scroll bar.

If the user moves the MarkText and then scrolls, the MarkText stays in the same screen position, and does not move with the rest of the cart. This happens for all unmoved MarkText items after the one moved, but any unmoved ones before it work fine. Once you scroll to where the item would no longer be visible, then it just disappears.

I was using 8.06 but upgraded to version 8.08 and the problem still exists.
See Attached Pictures.
Attachments
MarkText1.png
Original Location
MarkText1.png (8.57 KiB) Viewed 7782 times
MarkText2.png
Scrollbar Moved
MarkText2.png (10.04 KiB) Viewed 7740 times

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

Re: MarkText SeriesPt not scrolling Correct

Post by Yeray » Tue Mar 10, 2015 4:15 pm

Hello,

Take a look at this reply.
I've made a simple example using a TBarSeries:

Code: Select all

uses Series, Types;

var XOffset, YOffset: Array of Integer;
    MouseDownPos: TPoint;

procedure TForm1.FormCreate(Sender: TObject);
var s, i: Integer;
begin
  Chart1.Legend.Visible:=false;
  Chart1.View3D:=false;

  with Chart1.AddSeries(TBarSeries) do
  begin
    FillSampleValues;
    Marks.Arrow.Color:=clRed;
  end;

  SetLength(XOffset, Chart1[0].Count);
  SetLength(YOffset, Chart1[0].Count);

  for i:=0 to High(XOffset) do
  begin
    XOffset[i]:=0;
    YOffset[i]:=0;
  end;

  with Chart1.Tools.Add(TDragMarksTool) as TDragMarksTool do
  begin
    Series:=Chart1[0];
    OnDraggedMark:=DragMarksOnDragged;
  end;

end;

procedure TForm1.DragMarksOnDragged(Sender:TDragMarksTool; Index:Integer;
                                    Button:TMouseButton; Shift: TShiftState;
                                    X,Y: Integer);
begin
  if Assigned(Sender.Series) then
  begin
    if (Index>-1) and (Index<Length(XOffset)) then
    begin
      XOffset[Index]:=XOffset[Index]+X-MouseDownPos.X;
      YOffset[Index]:=YOffset[Index]+Y-MouseDownPos.Y;
    end;
  end;
end;

procedure TForm1.PlaceMarks;
var s, i, tmpSize, tmpX, tmpY: Integer;
begin
  Chart1.Draw;

  for s:=0 to Chart1.SeriesCount-1 do
    if Chart1[s] is TBarSeries then
      with Chart1[s] as TBarSeries do
      begin
        for i:=0 to Count-1 do
          with Marks.Positions[i] do
          begin
            tmpX:=CalcXPos(i);
            tmpY:=CalcYPos(i);

            Custom:=true;
            LeftTop.X:=tmpX + BarWidth div 2 - Marks.Item[i].Width div 2 + XOffset[i];

            if MarksOnBar then
              if MarksLocation=mlEnd then
                LeftTop.Y:=tmpY
              else
              begin
                tmpSize:=CalcYSizeValue(YValue[i]);
                if MarksLocation=mlStart then
                  LeftTop.Y:=tmpY+tmpSize-Marks.Height
                else
                  LeftTop.Y:=tmpY+(tmpSize div 2)-(Marks.Height div 2);
              end
            else
              LeftTop.Y:=tmpY-Marks.ArrowLength-Marks.Height;

            LeftTop.Y:=LeftTop.Y+YOffset[i];
            ArrowFrom:=Point(tmpX+BarWidth div 2, tmpY);
            ArrowTo:=Point(LeftTop.X+Marks.Item[i].Width div 2, LeftTop.Y);
          end;
      end;
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  PlaceMarks;
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  PlaceMarks;
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  PlaceMarks;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  MouseDownPos.X:=X;
  MouseDownPos.Y:=Y;
end;
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

INL2
Newbie
Newbie
Posts: 22
Joined: Mon Aug 18, 2008 12:00 am

Re: MarkText SeriesPt not scrolling Correct

Post by INL2 » Tue Mar 10, 2015 9:23 pm

Thanks, for the help. It has been along time since I had to work with these charts, could you add a bit more.

1. Supply the whole project so i can run the code and watch it work. (unknown items on compile MarksOnBar, MarksLocation, and mlEnd)

Or

2. Add some comments to PlaceMarks so I can figure out how to translate that into what I am doing.

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

Re: MarkText SeriesPt not scrolling Correct

Post by Yeray » Wed Mar 11, 2015 9:10 am

Hello,

Sorry, I took part of the code from an example using a newer version.
I've tested this with TeeChart v8:
draggingMarks_TeeChart8.zip
(1.81 KiB) Downloaded 669 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

Post Reply