Page 1 of 1

Aligning Left Axis for Multiple Charts

Posted: Wed Nov 22, 2006 6:40 pm
by 9242408
Hi,

Now I need to align the left axis on about 13 charts. This way looking at them all you could see the line ups for all the charts properly.

I didnt see anything in the features for it.


Thanks,

Tom

Posted: Thu Nov 23, 2006 6:55 am
by Marjan
Hi, Tom.

This has to be done manually through setting some of the axis/chart properties. Here is an example:

Code: Select all

procedure LeftAlignCharts(Const Charts: Array of TCustomChart; aLeft: Integer; aWidth: Integer);
var i: Integer;
begin
  for i := Low(Charts) to High(Charts) do
  // Left align charts
  With Charts[i] do
  begin
    Left := aLeft;
    Width := aWidth;
    Margins.Left := 0;
    Axes.Left.TitleSize := 15;
    Axes.Left.LabelsSize := 30;
    Axes.Left.LabelsAlign := alDefault;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // ...
  LeftAlignCharts([Chart1,Chart2],100,300);
end;

Posted: Fri Nov 24, 2006 4:32 pm
by 9242408
Thanks, that will get me going in the right direction!!!!

Posted: Tue Nov 28, 2006 12:27 pm
by 9242408
Ok got this working, however now my letters for the left axis titles are pushed together so its hard to even read at all. Any ideas on how to compensate for that?


Thanks,

Tom

Posted: Tue Nov 28, 2006 12:39 pm
by narcis
Hi Tom,

Is that axis labels overlap with axis title? If so, try using custom labels size as told here.

Posted: Tue Nov 28, 2006 12:43 pm
by 9242408
narcis wrote:Hi Tom,

Is that axis labels overlap with axis title? If so, try using custom labels size as told here.
No the space between the labels and the title is fine. The letters for the title are overlapping eachother. On screen it looks fine but the drawmetatocanvas deal for printing seems to be causing it. I thin the strechtodraw might have something to do with it maybe.


Tom

Posted: Tue Dec 05, 2006 12:13 pm
by Pep
Hi Tom,

it's difficult to know where is the problem without seeing the code. If you can send me a small app where I can see the problem (to pep@steema.com) and I'll take a look the code.

Posted: Tue Dec 05, 2006 12:22 pm
by Pep
Hi Tom,

btw, are you changing the Title font size ?
If so, have you used Font.Height instead of Font.Size for font size ?

Posted: Tue Dec 05, 2006 1:00 pm
by 9242408
I will try it pep and post back.

Thanks,

Tom

Posted: Tue Dec 05, 2006 1:34 pm
by 9242408
Pep,

Its almost like I need to do this:

Code: Select all

Chart1.LeftAxis.Title.Font.InterCharSize := 3;
But I do this it still doesnt seem to show up on the printout?


Thanks,

Tom

Posted: Thu Dec 14, 2006 1:55 pm
by Pep
Hi Tom,

it's strange, I've test it here just printing a Chart with left axis title (setting interCharSize) and I get correct title printed (with correct separation), here is the code I used :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
 Chart1.Axes.Left.Title.Caption:='my axis title';
 Chart1.Axes.Left.Title.Font.InterCharSize:=3;
end;

procedure TForm1.Button2Click(Sender: TObject);
var tmpMeta: TMetafile;
begin
  tmpMeta := Chart1.TeeCreateMetafile(True,Chart1.ClientRect);
  try
//    Printer.Orientation := poLandscape;
    Printer.BeginDoc;
    try
      Printer.Canvas.StretchDraw(Rect(10,10,Printer.PageWidth - 10, Printer.PageHeight - 10),tmpMeta);
    finally
      Printer.EndDoc;
    end;
  finally
    tmpMeta.Free;
  end;
end;