Page 1 of 1

assigning series to customaxis at runtime

Posted: Wed Nov 14, 2007 9:52 am
by 9236620
Hi,

I have a Chart axis added at runtime. Now I fail to assign a series to this axis:
procedure TForm1.TntButton1Click(Sender: TObject);
begin
ca := TChartAxis.Create(Chart1);
ca.Visible := true;
ca.Automatic := true;
ca.Horizontal := true;
ca.PositionPercent := 30;
ca.StartPosition := 20;
ca.EndPosition := 80;
//available Series from designtime
Series1.HorizAxis := THorizAxis(ca);
end;
Is suggest the cast does not work but I saw no alternative while I cannot create a custom THorizAxis at runtime.

Thanks, Messie

Posted: Wed Nov 14, 2007 9:58 am
by 9343260
Why you don't use

Code: Select all

ca := THorizAxis.Create(Chart1); 
?

I think creating a TChartAxis creates a vertical axis, and then you cannot assign it as a horizontal axis.

Posted: Wed Nov 14, 2007 10:18 am
by 9236620
Because THorizAxis is a type used for settings propertys
type THorizAxis = (aTopAxis, aBottomAxis, aBothHorizAxis, aCustomHorizAxis);

Unit
TeEngine

Description
Type describes Horizontal Axis type.

See also:
TChartSeries.HorizAxis
TChartSeries.HorizAxis is not the same as setting the "Horizontal Axis" in the Chart Editor. I need the way to set the horizontal axis according to the ChartEditor.

Messie

Posted: Wed Nov 14, 2007 11:05 am
by narcis
Hi Messie,

It seems to me you need to do this

Code: Select all

  Series1.CustomHorizAxis:=ca;
As you can see in Tutorial 4 - Axis Control, specially in the Multiple Custom axes section.

You'll find the tutorials at TeeChart's program group.