轉帖|其它|編輯:郝浩|2010-10-13 17:30:45.000|閱讀 2721 次
概述:本文主要介紹TChart控件在使用過程中遇見的問題問題極其使用技巧,希望對大家有幫助。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
一、 問題極其使用技巧
1、 TChart中如何實現只有Y軸的放大與縮小功能?
設置BottomAxis或者LeftAxis的Automatic:=false并同時設置Minimum,Maximum屬性
2、 如何固定TChart中的坐標,不使TChart中的坐標跟隨Series的變化而變化?
//設置底座標
with myChart.BottomAxis do
begin
Automatic:=false;
Minimum:=0;
LabelStyle := talText;
end;
//設置左坐標
with myChart.LeftAxis do
begin
Automatic:=false;
Minimum:=0;
Title.Angle:=270;
Title.Font:=Self.Font;
Title.Font.Charset:=ANSI_CHARSET;
Title.Font.Name:='@宋體';
Grid.Visible := False;
end;
//設置右坐標
with myChart.RightAxis do
begin
Automatic:=false;
Title.Font:=Self.Font;
Title.Font.Charset:=ANSI_CHARSET;
Title.Font.Name:='@宋體';
Title.Caption:='累計百分比(%)';
Maximum:=100;
Minimum:=0;
end;
3、 如何刪除一個圖形中的一個點?
使用Series的delete 方法
4、 如何修改一個點的X或者Y 值?
LineSeries1.YValue[3] := 27.1 ;
{In Bubble Series}
BubbleSeries1.RadiusValues.Value[ 8 ] := 8.1 ;
{In Pie Series}
PieSeries1.PieValues.Value[ 3 ] := 111 ;
5、 如果橫坐標是時間(日期),如何進行設置?
{First, you need to set the DateTime property to True in the desired X and/or Y values list.}
LineSeries1.XValues.DateTime := True ;
{Second, use the same above described methods, but give the values as Date, Time or DateTime values}
LineSeries1.AddXY( EncodeDate( 1996 , 1 , 23 ) , 25.4 , 'Barcelona' , clGreen );
6、 如何在chart中畫出的曲線某個點上標記出該點的值?
Series.Marks.Visible:=true;
Series.Marks.Style:=smsValue;
7、如何設置橫軸或者縱軸的增長率?
Chart.BottomAxis.Increment := DataTimeStep[ dtOneHour ] ;
Chart.RightAxis.Increment := 1000;
1.4.8 如何對圖象進行縮放?
TChart的ZoomRect或者ZoomPercent方法 (Pie圖可能不支持縮放)
二、 TChart可以繪制的圖形
Line ( TLineSeries)
FastLine (TFastLineSeries) 相對Line來說,它損耗了某些屬性從而來實現快速繪制
Bar (TBarSeries)
Horizontal bar (THorizBarSeries)
Area (TAreaSeries)
Point (TPointSeries)
Pie (TPieSeries)
Arrow (TArrowSeries)
Bubble (TBubbleSeries)
Gantt (TGanttSeries)
Shape (TChartShape)
三、 TChart的實時繪制
實時繪制對機器性能要求比較高,因此我們在編程的時候要注意下面幾個方面:
ü 使用2D圖形
ü 是Chart盡可能包含少的點
ü 如果需要,可以移除(remove)chart的legend(?????)和Title
ü 使用默認的字體和字體大小
ü 使用FastLineSeries
ü 使用實體(solid)畫筆和畫刷格式
ü 盡量避免使用圓形和環(huán)行bar樣式
ü 不要使用背景圖片和漸變效果樣式
ü 把Chart的BevelInner和BevelOUter屬性設置為bcNone
ü 如果需要,把TChart的AxisVisible屬性設置為False
ü 把BufferedDisplay設置為false可以加速chart的重繪
四、 Scrolling
TChart有4中scroll選擇(AllowPanning屬性),分別是 不允許Scroll ( pmNone) ; 水平Scroll (pmHorizontal) ; 垂直Scroll (pmVertical) ; 水平和垂直Scroll (pmBoth)
Procedure Scroll(Const Offset:Double; CheckLimits:Boolean);
例子如下:
Chart1.BottomAxis.Scroll( 1000, True );這段代碼也等同于
With Chart1.BottomAxis do
Begin
Automatic:=false;
SetMinMax( Minimum0+1000, Maximum+1000 );
End;
五、 TChart中的全局變量
ü TeeScrollMouseButton := mbRight;設置鼠標右鍵為TChart滾動鍵(默認)
ü TeeScrollKeyShift := [ ssCtrl ]; 要按住Control鍵才可以使Scroll滾動
六、 TChartSerries使用技巧
1、 運行時候創(chuàng)建一個Serries, 三種方法:
(1) Var MySeries : TBarSeries ;
MySeries := TBarSeries.Create( Self );
MySeries.ParentChart := Chart1 ;
(2) Chart1.AddSeries( TBarSeries.Create( Self ) );
(3) Var MyClass : TChartSeriesClass;
MyClass := TBarSeries ;
Chart1.AddSeries( MyClass.Create( Self ) );
2、 獲得TChart中的Serries數組,也有三種方法
(1) MySeries := Chart1.SeriesList [ 0 ]
(2) MySeries := Chart1.Series [ 0 ]
(3) MySeries := Chart1 [ 0 ]
3、 SerriesCount屬性獲得SeriesList中Series的個數
4、 隱藏TChart中的Series有三種方法,但是效果不等價
(1) Series1.Active:=False; 僅僅隱藏,當設置為true的時候還可以顯示出來
(2) Series1.ParentChart:=nil ; 隱藏,重新設置ParentChart為TChart時候可以顯示
(3) Series1.Free; 刪除了Series. 不可以恢復
5、 TChart中的數據排序
With Series1 do
begin
YValues.Order:=loAscending;
YValues.Sort;
Repaint;
end;
Ø 定位一個點(Loacate a point)
Series1.XValues.Locate(123);
Ø XValue和YValue都擁有的屬性Total , TotalABS , MaxValue , MinValue
慧都2010促銷季開幕,TeeChart for .NET 8折促銷!詳情咨詢:400-700-1020或023-66090381活動詳情://ke049m.cn/zh-CN/Products_cn/TeeChart_chinese.html
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:網絡轉載