How to change Mark position

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 30, 2007 2:46 pm

Hi pssdelphi,

That's because if marks have a custom position you have to update them when scrolling, zooming and unzooming, for example:

Code: Select all

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

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

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

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  UpdateMarks;
end;
Regarding the adding many points issue, which is the exact problem?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

pssdelphi
Newbie
Newbie
Posts: 29
Joined: Thu Oct 21, 2004 4:00 am

Post by pssdelphi » Tue Jan 30, 2007 6:44 pm

Upon playing with the problem some more, the disattachment of the mark with the point and all the marks to that point getting jumbled up has to do with adding a point to the left of an existing point.

With this is code:

Code: Select all

procedure TForm1.MoveLineMark(Num: integer);
begin
with Series1.Marks.Positions[Num] do begin
  Custom:=True;
  LeftTop.Y:=LeftTop.Y-10;
end;
Series1.Repaint;
end;

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  xs, ys: double;
  ja: integer;
begin
  xs:=Series.XScreenToValue(x);
  ys:=Series.YScreenToValue(y);
  ja:=Series1.AddXY(xs,ys);
  Chart1.Refresh;
  MoveLineMark(ja);
end;
Screen shots showing the problem:

http://www.fileden.com/pview.php?fid=146728&fname=1.jpg
http://www.fileden.com/pview.php?fid=146729&fname=2.jpg

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jan 31, 2007 10:24 am

Hi pssdelphi,

Thanks for the information, now I could see what the exact problem is. In Chart1ClickSeries when adding a new point to the series, by default x values are sorted in ascending mode. That's why ja variable doesn't have the desired index and labels are messed up. For this to work you should set x values order to none:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues(3);
  Series2.FillSampleValues(10);

  Series1.XValues.Order := loNone;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

pssdelphi
Newbie
Newbie
Posts: 29
Joined: Thu Oct 21, 2004 4:00 am

Post by pssdelphi » Wed Jan 31, 2007 4:55 pm

Thanks for the fix. Any chance marks might be reworked in a future version so there is intergated attachment of the custom marks, so sort order, scrolling, etc. work naturally?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Feb 01, 2007 11:33 am

Hi pssdelphi,

The problem is not the marks itself, it's series default sorting consequences. We have found some issues related to this lately. We may consider reviewing this for future releases but I'm afraid this would involve major series re-design.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply