Problems with Chart1.Axes.Bottom.Items.Clear;
Posted: 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:
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;