翻譯|使用教程|編輯:王香|2019-05-27 13:51:08.307|閱讀 565 次
概述:TeeChart Pro提供了一個(gè)空的Chart Canvas作為數(shù)據(jù)系列的背景。這意味著沒有預(yù)定義圖表類型。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
已加入在線訂購,現(xiàn)在搶購可立享特別優(yōu)惠!!!
TeeChart Pro提供了一個(gè)空的Chart Canvas作為數(shù)據(jù)系列的背景。這意味著沒有預(yù)定義圖表類型。您可以將所需的圖表類型定義為要顯示的系列類型的混合。由于某些系列類型的特殊性質(zhì),在圖表上混合使用一些系列類型是不切實(shí)際的。當(dāng)您添加新系列時(shí),TeeChart會(huì)通過在圖表庫中顯示不適合的系列類型來幫助您。您可以在一個(gè)圖表中放置的系列數(shù)量沒有實(shí)際限制。
使用圖表編輯器(參見教程1)或按代碼添加系列。
procedure TForm1.Button2Click(Sender: TObject); var tmpLineSeries:TLineSeries; begin tmpLineSeries:=TLineSeries.Create(self); Chart1.AddSeries(tmpLineSeries); tmpLineSeries.FillSampleValues(10); end;
添加到圖表中的系列將自動(dòng)將左軸和下軸作為參考軸。您可以通過選擇相關(guān)系列的“系列常規(guī)”頁面來更改圖表編輯器中的參考軸。有4個(gè)軸可供選擇,Top,Left,Bottom和Right。通過代碼,更改軸將如下所示:
With Series1 do begin HorizAxis := aTopAxis; VertAxis := aRightAxis; end;
每個(gè)軸可以關(guān)聯(lián)1個(gè)以上的系列。TeeChart將決定適合與Axis匹配的系列的最佳比例,但您可以自己更改Axis音階(參見Axis Tutorial)。可以添加附加軸,它們將復(fù)制與前4個(gè)軸相對(duì)應(yīng)的刻度(參見教程部分附加軸)。
您可以使用Series作為另一個(gè)Series的數(shù)據(jù)源。通過設(shè)置第二系列的數(shù)據(jù)源,可以使用圖表編輯器完成此操作。轉(zhuǎn)到“系列”選項(xiàng)卡“數(shù)據(jù)源”頁面。選擇“Function”作為數(shù)據(jù)源類型。將出現(xiàn)兩個(gè)列表框,可用系列和選定系列。選擇要用作當(dāng)前系列的數(shù)據(jù)源的系列,然后在上面名為Function:的Combobox中,選擇Copy作為功能類型。請(qǐng)注意,以這種方式,任何Series都可以定義為其他Series的函數(shù),F(xiàn)unction Type可以是Function組合框中可用的列表中的任何一個(gè)。要通過代碼執(zhí)行相同操作,請(qǐng)參閱下文:
procedure TForm1.BitBtn2Click(Sender: TObject); begin With Series2 do begin Datasource:=Series1; SetFunction(TAverageTeeFunction.Create(Self)); FunctionType.Period := 4; CheckDatasource; end end;
使用圖表編輯器可以非常輕松地更改系列順序。轉(zhuǎn)到編輯器的金喜正規(guī)買球,突出顯示要移動(dòng)的系列。使用右側(cè)的箭頭按鈕以系列順序向上或向下移動(dòng)系列。系列訂單將決定系列在圖表中相對(duì)于其他系列的相對(duì)顯示位置。通過代碼使用SeriesList屬性或ExchangeSeries方法。
Chart1.ExchangeSeries(0, 1); //Change Series(0) with Series(1) in the index order
注意。交換Series后,系列的索引將被更改。因此,如果代碼重新運(yùn)行,上面的代碼行將永久地交換2系列'0'和'1',因?yàn)?變?yōu)?,1變?yōu)?。
將系列設(shè)置為“Active:=False”將從圖表中隱藏系列,但保持其數(shù)據(jù)內(nèi)容不變。
TeeChart系列通過TChartValueList組件將其值存儲(chǔ)在可訪問和可修改的Valuelist中。
您可以訪問列表中的任何值:
ShowMessage(FloatToStr(Series1.XValues[3])); //Displays value of 4th point (index starts at 0) in Series1
以這種方式訪問的值可用于設(shè)置系列數(shù)據(jù)的陷阱條件:
With Series1 do begin For t := 0 To Count - 1 do begin If YValues[t] > 9 Then ShowMessage('Value: ' + FloatToStr(XValues[t]) + ', ' + FloatToStr(YValues[t]) + ' exceeds limit'); end; end;
可以通過一些Series方法和幾個(gè)Chart事件使用的PointIndex點(diǎn)獲得相同的值。
procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Showmessage('ValueIndex is: ' + IntToStr(ValueIndex)); Showmessage('Point''s Y value is: ' + FloatToStr(Sender.YValues.Value[ValueIndex])); Chart1.CancelMouse:=True; //Use CancelMouse to prevent Zoom event activating end;
單擊3D系列時(shí),只有前平面上的單擊才會(huì)被識(shí)別為系列單擊。
此代碼根據(jù)用戶的鼠標(biāo)單擊修改BarSeries Bar的值。
//Use the OnClickSeries or OnClickBackground event to determine where the user has clicked.procedure TForm1.Chart1ClickBackground(Sender: TCustomChart; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin If (Int(Chart1.Axes.Bottom.CalcPosPoint(X)) > -1) Then Case Ord(Button) of 0 : UpdatePoint(Chart1.Axes.Bottom.CalcPosPoint(X), Chart1.Axes.Left.CalcPosPoint(Y)); end; end; procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin UpdatePoint(ValueIndex, Chart1.Axes.Left.CalcPosPoint(Y)); Chart1.CancelMouse:=True; //Use CancelMouse to prevent Zoom event activatingend;
在這兩種情況下,請(qǐng)調(diào)用UpdatePoint Sub例程來修改Bar的值:
Procedure TForm1.UpdatePoint(Bar, Y : Double); begin If Round(Bar) < Series1.Count Then begin Series1.YValues[Round(Bar)] := Int(Y); Chart1.refresh; end; end;
購買TeeChart Pro VCL/FMX正版授權(quán),請(qǐng)點(diǎn)擊“”喲!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: