Problems with Chart1.Axes.Bottom.Items.Clear;

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Friis
Newbie
Newbie
Posts: 23
Joined: Mon May 07, 2012 12:00 am

Problems with Chart1.Axes.Bottom.Items.Clear;

Post by Friis » Mon Feb 18, 2013 10:44 am

Hi,

When I change between TAxisLabelSTyle "TalValue" and "TalMark" and also using the Chart1.Axes.Bottom.Items.Clear; method I have problems with the bottom axis - it simply disappears.

Try the following: (see code below)

1) Press button1 once (bottom axis TAxisLabelSTyle is talValue; it works fine)
2) Press button2 once (bottom axis TAxisLabelSTyle is talMark; it works fine)
3) Press button1 once (bottom axis TAxisLabelSTyle is talValue; it does NOT work - the values at the bottomaxis disappears)

It seems that the problem is with "Chart1.Axes.Bottom.Items.Clear;" - When that command has been called; then there is problems...

Put a TChart (name Chart1) and two buttons, Button1 and Button2 on a Form:

Code: Select all

procedure TForm10.Button1Click(Sender: TObject);
var i: Integer;
begin
Chart1.FreeAllSeries();
Chart1.RemoveAllSeries;

  Chart1.View3D:=false;
  Chart1.Axes.Bottom.Items.Clear;

  Chart1.AddSeries(TFastLineSeries);
  Chart1.AddSeries(TFastLineSeries);

  for i:=0 to 10 do
  begin
    Chart1[0].AddXY(i, i, 'label ' + IntToStr(Chart1[0].Count));
    Chart1[1].AddXY(i+0.5, i+10, 'label ' + IntToStr(Chart1[1].Count));
  end;

  Chart1.BottomAxis.LabelStyle := TalValue;

end;



procedure TForm10.Button2Click(Sender: TObject);
var i: Integer;
begin
Chart1.FreeAllSeries();
Chart1.RemoveAllSeries;

  Chart1.View3D:=false;

  Chart1.AddSeries(TFastLineSeries);
  Chart1.AddSeries(TFastLineSeries);

  for i:=0 to 10 do
  begin
    Chart1[0].AddXY(i, i, 'label ' + IntToStr(Chart1[0].Count));
    Chart1[1].AddXY(i+0.5, i+10, 'label ' + IntToStr(Chart1[1].Count));
  end;

  Chart1.Axes.Bottom.Items.Clear;
  for i:=0 to Chart1[0].Count-1 do
    if Chart1[0].Labels[i]<>'' then
      Chart1.Axes.Bottom.Items.Add(Chart1[0].XValue[i], Chart1[0].Labels[i]);

end;

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

Re: Problems with Chart1.Axes.Bottom.Items.Clear;

Post by Yeray » Mon Feb 18, 2013 11:24 am

Hi,

Items.Clear activates the custom labels list and clears it. It is thought to be used before Items.Add.
If you just want to use the regular automatic labels instead of the items list, try setting automatic:=true:

Code: Select all

Chart1.Axes.Bottom.Items.Automatic:=true;
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