Page 1 of 1

Title ignored when using a custom axis (bug?)

Posted: Wed Aug 24, 2005 1:46 am
by 9343038
I created a custom axis, with Horizontal = true, OtherSide=true, Position=0 so it sits on top of my chart and the text higher. When I select the series horizontal axis to be the top axis, the chart gets smaller so the title area is not obstructed. When I select my custom axis, the chart get larger and the axis labels 'overwrite' the title area. My custom axis inherits from the TChartAxis, and introduces a new LabelValue function. I did not find a RegisterAxis procedure; could that be the problem?
--Paul

small example of problem

Posted: Fri Aug 26, 2005 2:57 pm
by 9343038
Below a small example that shows the problem
--Paul

Code: Select all

procedure TForm1.FormShow(Sender: TObject);
var
   mySeries: TBarSeries;
   HorizAxis  : TChartAxis;
begin
mySeries := TBarSeries.Create(Chart1);
mySeries.FillSampleValues(6);
Chart1.AddSeries(mySeries);
HorizAxis := TChartAxis.Create(Chart1);
mySeries.CustomHorizAxis := HorizAxis;
with HorizAxis
do begin
   Horizontal := true;
   OtherSide := true;
   LabelsFont.Size := 14;
   end;
end;


Posted: Fri Aug 26, 2005 3:34 pm
by narcis
Hi Paul,

This is default custom axes behaviour. To avoid that you can add something like the code in the Workaround section in the snippet below.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
   mySeries: TBarSeries;
   HorizAxis  : TChartAxis;
begin
  mySeries := TBarSeries.Create(Chart1);
  mySeries.FillSampleValues(6);
  Chart1.AddSeries(mySeries);
  HorizAxis := TChartAxis.Create(Chart1);
  mySeries.CustomHorizAxis := HorizAxis;
  with HorizAxis do
  begin
     Horizontal := true;
     OtherSide := true;
     LabelsFont.Size := 14;
  end;

  //Workaround
  Chart1.MarginUnits:=muPercent;
  Chart1.MarginTop:=10;
  With Chart1.Title do
  begin
    CustomPosition:=true;
    Top:=10;
    Left:=Chart1.Width div 2;
  end;
  //End Workaround
end;