Page 1 of 1

Chart dimension and legend

Posted: Thu Jun 11, 2009 12:32 pm
by 10050873
Hello,

I would like to have the chart dimension always the same even if the legend is hidden or not. How can i do to block the automatic autosize?

Regards

Re: Chart dimension and legend

Posted: Fri Jun 12, 2009 1:10 pm
by yeray
Hi Calou,

The legend visible in one of the four default positions, adds an extra margin to the chart. So what you could do is to position the legend manually by the start. Something like following:

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TLineSeries.Create(self));
  Chart1[0].FillSampleValues(25);

  Chart1.Legend.CustomPosition := true;
  Chart1.MarginRight := 12;
  Chart1.Draw;
  Chart1.Legend.Left := Chart1.Axes.Bottom.IEndPos + 20;
  Chart1.Legend.Top := Chart1.Axes.Left.IStartPos;
  CheckBox1.Checked := true;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  Chart1.Legend.Visible := CheckBox1.Checked;
end;