1
我正在以编程方式创建一个tChart(Delphi2007,TeeChar 7免费版)。我想设置图表维度,也许更改宽高比,但我没有得到有意义的结果更改宽度和高度属性。我试着改变轴TickLength没有运气。我从dfm文件复制了TChart的相关属性,不要忘记任何有意义的东西。仅当我编辑X和Y最大值和最小值时,图形的方面才会改变,但这还不够。以编程方式更改TChart大小
这是我的原始图表和“重新格式化”的图表,因为您可以看到两者的图表尺寸均为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;
非常感谢你,错误是在我的鼻子下面,我看不到它!我认为在安全方面使用“with”只是为了节省一些打字的时间来设置一大堆属性,但是现在,“with”的邪恶已经显示给我! – lib 2012-07-31 15:37:38
我想这已经发生在很多Delphi程序员身上。过程/函数调用中的一种常见做法是使用“A”开始每个参数名称。这可能会将您保存在此处,但正如链接中所述,请避免使用“with”关键字。 – 2012-07-31 15:43:05
+1。如果可能的话,我会为最后一句增加第二个赞成票。 :-) – 2012-07-31 16:46:43