Delphi 以编程方式更改TChart大小

Delphi 以编程方式更改TChart大小,delphi,delphi-2007,teechart,Delphi,Delphi 2007,Teechart,我正在以编程方式创建一个tChart(Delphi2007,TeeChar 7免费版)。我想设置图表维度,也许还可以更改纵横比,但更改宽度和高度属性并没有得到有意义的结果。我也尝试过改变轴的长度,但没有成功。我从dfm文件中复制了TChart的相关属性,并没有忘记任何有意义的内容。只有编辑X和Y的最大值和最小值时,图形的外观才会改变,但这还不够 这是我的原始图表和“重新格式化”的图表,您可以看到,两者的图表尺寸都是400 x 250。是否有用于调整图表大小的特定属性?我希望轴相应地调整大小,可以

我正在以编程方式创建一个tChart(Delphi2007,TeeChar 7免费版)。我想设置图表维度,也许还可以更改纵横比,但更改宽度和高度属性并没有得到有意义的结果。我也尝试过改变轴的长度,但没有成功。我从dfm文件中复制了TChart的相关属性,并没有忘记任何有意义的内容。只有编辑X和Y的最大值和最小值时,图形的外观才会改变,但这还不够

这是我的原始图表和“重新格式化”的图表,您可以看到,两者的图表尺寸都是400 x 250。是否有用于调整图表大小的特定属性?我希望轴相应地调整大小,可以吗?谢谢你的帮助

以下是与TChart相关的代码:

procedure CreateChart(parentform: TForm);
//actually formatChart is a CreateChart anf fChart a member of my class
begin
  fchart:= TChart.Create(parentform);
  fchart.Parent:= parentform;
  fchart.AxisVisible := true;
  fchart.AutoSize := false;
  fChart.color := clWhite;
  fchart.BottomAxis.Automatic := true;
  fchart.BottomAxis.AutomaticMaximum := true;
  fchart.BottomAxis.AutomaticMinimum := true;
  fchart.LeftAxis.Automatic := true;
  fchart.LeftAxis.AutomaticMaximum := true;
  fchart.LeftAxis.AutomaticMinimum := true;
  fchart.view3D  := false;
end

 procedure formatChart(width, height, xmin, xmax, ymin, ymax: double);
 //actually formatChart is a method anf fChart a member of my class
 begin
   with fChart do  
     begin
       Color := clWhite;
       fChart.Legend.Visible := false;
       AxisVisible := true;
       AllowPanning := pmNone;
       color := clWhite;
       Title.Visible := False;
       BottomAxis.Minimum := 0; //to avoid the error maximum must be > than min
       BottomAxis.Maximum := xmax;
       BottomAxis.Minimum := xmin;
       BottomAxis.ExactDateTime := False ;
       BottomAxis.Grid.Visible := False ;
       BottomAxis.Increment := 5 ;
       BottomAxis.MinorTickCount := 0;
       BottomAxis.MinorTickLength := 5;
       BottomAxis.Ticks.Color := clBlack ;
       BottomAxis.TickOnLabelsOnly := False;
       DepthAxis.Visible := False;
       LeftAxis.Automatic := false;
       LeftAxis.AutomaticMaximum := false;
       LeftAxis.AutomaticMinimum := false;
       LeftAxis.Minimum := ymin;
       LeftAxis.Maximum := ymax;
       LeftAxis.Minimum := ymin;
       LeftAxis.TickLength := 5;
       Width := round(width);
       Height := round(height);
       View3D := False ;
     end;
 end;

我认为这里有名字冲突。您正在将
与fChart
一起使用,并且
fChart
的属性
高度
宽度
。虽然在过程调用中使用了相同的名称,但使用了宽度和高度:

Width := Round(width); // The fChart property Width is used on both sides.
Height := Round(height); // The fChart property Height is used on both sides.
重命名过程调用中的名称,它将按预期工作


更好的方法是,避免将
关键字一起使用。请参阅:。

我认为这里存在名称冲突。您正在将
与fChart
一起使用,并且
fChart
的属性
高度
宽度
。虽然在过程调用中使用了相同的名称,但使用了宽度和高度:

Width := Round(width); // The fChart property Width is used on both sides.
Height := Round(height); // The fChart property Height is used on both sides.
重命名过程调用中的名称,它将按预期工作


更好的方法是,避免将
关键字一起使用。请参阅:。

非常感谢,错误在我眼皮底下,我看不见!我曾想过为了安全起见,使用“with”只是为了在设置一长串属性时节省一些输入,但现在“with”的邪恶已经向我展示了!我想这已经发生在许多Delphi程序员身上了。过程/函数调用中的常见做法是以
A
开头每个参数名。这本可以将您保存在这里,但如链接中所述,请避免使用“with”关键字。+1。如果可以的话,我会对最后一句话投第二票。:-)+我希望有人能用杀死
,因为它会在很多层面上导致失败。@Jeroen拒绝使用它很容易自己杀死它。非常感谢,错误就在我眼皮底下,我看不见它!我曾想过为了安全起见,使用“with”只是为了在设置一长串属性时节省一些输入,但现在“with”的邪恶已经向我展示了!我想这已经发生在许多Delphi程序员身上了。过程/函数调用中的常见做法是以
A
开头每个参数名。这本可以将您保存在这里,但如链接中所述,请避免使用“with”关键字。+1。如果可以的话,我会对最后一句话投第二票。:-)+我希望有人能用
杀死
,因为它会在很多层面上导致失败。@Jeroen拒绝使用它很容易让你自己杀死它。