1

プログラムでtChartを作成しています(Delphi2007、TeeChar 7無料版)。グラフの寸法を設定して縦横比を変更したいのですが、幅と高さのプロパティを変更しても意味のある結果が得られません。軸の TickLength も変更してみましたが、うまくいきませんでした。TChart の関連するプロパティを dfm ファイルからコピーしました。意味のあるものを忘れないようにします。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;
4

1 に答える 1

6

ここに名前の競合があると思います。with fChart、およびプロパティHeightWidthを使用しています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さらに良いことに、キーワードの使用は避けてください。参照: Delphi の "with" キーワードは悪い習慣ですか? .

于 2012-07-31T15:07:06.170 に答える