TBarSeries - Problems on accessing BarChart Marks

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
holgerBig
Newbie
Newbie
Posts: 3
Joined: Thu Feb 06, 2020 12:00 am

TBarSeries - Problems on accessing BarChart Marks

Post by holgerBig » Wed Feb 19, 2020 10:39 am

I have a chart with two BarSeries. Here I would like to display the Bar-Marks at a different position. When changing the position I always get exceptions at different positions.
The problem is that the BarSeries are well drawn, but some entries in the Marks.Positions-List are null. Then it crashes.
What is the problem?

Creating the series

Code: Select all

procedure TForm1.Button3Click(Sender: TObject);
var i, val : integer
begin
  for  i := 0 to 30 do
  begin
    val := random(50)+50;
    chart1.Series[0].AddXY(i+1, val, format('Mark: %d', [i+1]), clGreen);
    val := random(50)+50;
    chart1.Series[1].AddXY(i+1, val, format('Mark: %d', [i+1]), clRed);
    dt := dt + 1;
  end;
  Chart1.Draw();
  PlaceMarks();
end;
... and change the mark position

Code: Select all

procedure TForm1.PlaceMarks2;
var s, i, w1, w2, w3, tmpSize: 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
            if (marks.Visible = true) then
            begin
              Custom:=true;     // => Exception !!!! (Marks.Position[i] is null)
              Marks.Angle := 90;
              LeftTop.X := LeftTop.X;
            end;
          end;
      end;

end;

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TBarSeries - Problems on accessing BarChart Marks

Post by Marc » Wed Feb 19, 2020 1:14 pm

Hello,

You need to set:

Code: Select all

  chart1.Series[0].Marks.AutoPosition := False;
  chart1.Series[1].Marks.AutoPosition := False;
otherwise TeeChart will not create/render Marks at locations that are obscured by others.

Regards,
Marc Meumann
Steema Support

Post Reply