Delphi 控制TChart图表控件往左移
Delphi 控制TChart图表控件往左移
昨天写一个小工具应用到TChart控件,TChart控件也是非常复杂,里面属性和方法繁多而庞大,但是功能也是真的强大。在使用TChart图表控件的时候遇到一个难题,就是用代码控制TChart图表控件根据添加的最新数据往做移动最后停在最后一条数据。经过长时间的资料查找和反复测试。最终还是解决了这个问题。为了记录一下也方便遇到此问题的朋友快速解决问题,所以公布一下解决办法。代码如下:
最主要是使用BottomAxis.SetMinMax方法。希望能帮到需要的人。
procedure TfrmMain.ViewLastPage; var i:Integer; begin for I := 0 to pnlMain.ControlCount-1 do begin if pnlMain.controls[i] is TChart then begin with (pnlMain.controls[i] as TChart) do begin if Tag< GetMaxValuesCount then begin Tag := Tag +1; BottomAxis.SetMinMax(Tag-30,Tag); end; end; end; end; end;

浙公网安备 33010602011771号