我正在以编程方式创建一个 tChart(Delphi2007,TeeChar 7 免费版)。我想设置图表尺寸并可能更改纵横比,但是更改 Width 和 Height 属性没有得到有意义的结果。我也尝试更改轴 TickLength ,但没有运气。我从 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;