Page 1 of 1

Drag mark doesn't follow the mouse pointer during a panning

Posted: Fri Jul 11, 2008 9:12 am
by 9336299
Hi Steema support,

We have a trouble with drag mark when it doesn't follow the chart during a panning.
Please see more detail in images that we uploaded on your upload page.
There are two images: [Dragmark.jpg] and [Dragmark_Defect.jpg] with user is SiA.

Thanks and best regards.

Posted: Fri Jul 11, 2008 9:24 am
by narcis
Hi SiA,

For this to work you need to set custom marks positions set to a relative position in the chart and update them when chart is being zoomed or scrolled. You'll find an example here.

Posted: Mon Jul 14, 2008 9:05 am
by 9336299
Thanks for your reply,

We tried to apply your idea on our situation.
But we couldn't keep a modified drag mark following the mouse pointer during panning and set it to new relative position.
In fact, we only can reset drag mark position after panning by clearing all marks position and repaint.

Posted: Mon Jul 14, 2008 9:14 am
by narcis
Hi SiA,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here and let us know the exact TeeChart version you are using?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Mon Jul 14, 2008 11:19 am
by 9336299
Hi Narcis,

With this code, we can set the drag mark following the mouse pointer during panning, zooming and reset drag mark position after panning by clearing all marks position.

procedure TTeeChartExample.UpdateMarks;
var i: Integer;
begin
{Chart1.Draw();
for i:=0 to Chart1.Series[0].Count-1 do
begin
With Chart1.Series[0].Marks.Positions.Position do
Begin
Custom:=True;
LeftTop.X := Chart1.Series[0].CalcXPos(i);
LeftTop.Y := Chart1.Series[0].CalcYPos(i) - 10;
end;
end;
Chart1.Series[0].Marks.Arrow.Visible:=false;
Chart1.Series[0].Repaint;}
Chart1.Series[0].Marks.Positions.Clear;
Chart1.Series[0].Marks.ParentSeries.Repaint;
end;

procedure TTeeChartExample.Chart1Zoom(Sender: TObject);
begin
UpdateMarks;
end;

procedure TTeeChartExample.Chart1Scroll(Sender: TObject);
begin
UpdateMarks;
end;

procedure TTeeChartExample.Chart1UndoZoom(Sender: TObject);
begin
UpdateMarks;
end;


but we don't know how to set a modified drag mark position to new relative position.
Please find the DragMarkTeeChartExample.zip and ExpectedBehavior.doc that we uploaded for your more detail(name : Sia, email: lquocthanh@yahoo.com).

Thanks and best regards.

Posted: Mon Jul 14, 2008 11:49 am
by narcis
Hi SiA,

Thanks for the information. In that case you can achieve what you request like this:

Code: Select all

procedure TTeeChartExample.TeeChart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbRight) then
  begin
    if(FastLineSeries1.Marks.Visible = false) then
      ShowMarks1.Caption := 'Show Marks'
    else
      ShowMarks1.Caption := 'Hide Marks';
    PopupMenu1.Popup(X+Left,Y+Top);
  end;

  if (Button = TeeChart1.ScrollMouseButton) then
  begin
    X0:=X;
    Y0:=Y;
    X1:=-1;
    Y1:=-1;
  end;
end;

procedure TTeeChartExample.ShowMarks1Click(Sender: TObject);
begin
  FastLineSeries1.Marks.Visible := not FastLineSeries1.Marks.Visible;
end;

procedure TTeeChartExample.UpdateMarks;
var i: Integer;
begin
  if ((X1<>-1) and (Y1<>-1)) then
  begin
    TeeChart1.Draw();
    TeeChart1[0].Marks.Arrow.Visible:=true;

    for i:=0 to TeeChart1[0].Count-1 do
    begin
      With TeeChart1[0].Marks.Positions.Position[i] do
      Begin
        Custom:=True;
        LeftTop.X := LeftTop.X + (X1-X0);
        LeftTop.Y := LeftTop.Y + (Y1-Y0);

        ArrowFrom.X:=LeftTop.X + (Width div 2);
        ArrowFrom.Y:=LeftTop.Y + Height;

        ArrowTo.X:=TeeChart1[0].CalcXPos(i);
        ArrowTo.Y:=TeeChart1[0].CalcYPos(i);
      end;
    end;

    TeeChart1.Series[0].Repaint;
  end;
end;

procedure TTeeChartExample.TeeChart1Zoom(Sender: TObject);
begin
  //UpdateMarks;
end;

procedure TTeeChartExample.TeeChart1UndoZoom(Sender: TObject);
begin
  //UpdateMarks;
end;

procedure TTeeChartExample.TeeChart1Scroll(Sender: TObject);
begin
  //UpdateMarks;
end;

procedure TTeeChartExample.TeeChart1MouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if (Button = TeeChart1.ScrollMouseButton) then
  begin
    X1:=X;
    Y1:=Y;

    UpdateMarks;
  end;
end;
I'm going to send you modified project too.

Posted: Tue Jul 15, 2008 6:26 am
by 9336299
Thanks Narcis,

After modifying a bit:

Code: Select all

procedure TTeeChartExample.UpdateMarks;
var i: Integer;
begin
  if ((X1<>-1) and (Y1<>-1)) then
  begin
    TeeChart1.Draw();
    TeeChart1[0].Marks.Arrow.Visible:=true;

    for i:=0 to TeeChart1[0].Count-1 do
    begin
      With TeeChart1[0].Marks.Positions.Position[i] do
      If Custom = True then
      Begin
        //Custom:=True;
        LeftTop.X := LeftTop.X + (X1-X0);
        LeftTop.Y := LeftTop.Y + (Y1-Y0);

        ArrowFrom.X:=LeftTop.X + (Width div 2);
        ArrowFrom.Y:=LeftTop.Y + Height;

        ArrowTo.X:=TeeChart1[0].CalcXPos(i);
        ArrowTo.Y:=TeeChart1[0].CalcYPos(i);
      end;
    end;

    TeeChart1.Series[0].Repaint;
  end;
end;
I could set a modified drag mark position to new relative position.

But there are some unexpected behavior:
-the drag cannot follow mouse pointer during panning
-during panning (because panning defect), length of arrow of drag mark is strength longer and longer.

Hope this will be considered as a fix in future release!
[/code]