Can marks be moved horizontally?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
mLapido
Newbie
Newbie
Posts: 24
Joined: Wed Mar 24, 2004 5:00 am
Location: Brasil
Contact:

Can marks be moved horizontally?

Post by mLapido » Mon Jan 03, 2005 1:37 pm

Is it possible/How do I reposition a mark horizontally? In a bar chart, for example...???

regards,
Milton Lapido

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Jan 03, 2005 1:55 pm

Hi, Milton.

Yes, you can fully customize the position of each series mark. For example, the following code centers all series marks vertically and left aligns them horizontally:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues(5);
end;

procedure TForm1.AlignMarks;
var i: Integer;
begin
  // no need for arrows
  Series1.Marks.Arrow.Visible := False;
  for i := 0 to Series1.Count -1 do
    With Series1.Marks.Positions.Position[i] do
    begin
      Custom := True;
      LeftTop.Y := Series1.CalcYPosValue(Series1.YValues[i]*0.5);
      LeftTop.X := Series1.CalcXPos(i) - Series1.Marks.Width;
    end;
  Chart1.Repaint;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  AlignMarks;
end;
The only thing you should be aware of is that mark positions are created ONLY after the chart is drawn for the first time. In case you have to change mark positions before chart is drawn for the first time, you can either create mark positions by hand or force chart draw by calling chart Draw method.
Marjan Slatinek,
http://www.steema.com

Post Reply