翻譯|使用教程|編輯:王香|2018-10-15 10:45:33.000|閱讀 830 次
概述:本文詳細介紹了在TeeChart Pro ActiveX中入門知識之構建圖表并填充數據系列(下),可以自由地在運行時添加和刪除不同的數據系列類型,而無需重新定義整個圖表的外觀。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載TeeChart Pro ActiveX最新版本】
在圖表編輯器中選擇“Series”選項卡以顯示“Series”配置屬性。“Series”頁面上的第五個選項卡是數據源選項卡。
如果您的數據源是OLE DB或ODBC兼容,那么您可以直接在圖表編輯器中映射數據。
從“Data Source”頁面的下拉列表框中 選擇“Dataset”,然后選擇“New...”按鈕以定義連接源。
使用默認的Microsoft OLE DB Provider for ODBC Drivers Provider 構建新的連接字符串使您可以從任何具有有效用戶DSN的ODBC數據源中進行選擇,包括TeeChart Pro數據庫。
您可以從可用的表列表中選擇一個表,也可以為數據源編寫自己的SQL查詢。SQL查詢可以保存為TXT文件并以此形式引入。
選擇確定將創建整個連接操作的記錄,在本例中稱為DataSet1,并返回到先前的數據源屏幕,您可以在其中選擇要添加到系列的列。要填充我們的新Bar系列,我們只需要標簽和條形值,其中標簽將在水平(默認情況下為底部)軸上讀取,其中Bar是條形圖垂直高度的值。完成這些字段后,您可以選擇“ 關閉”或“ 應用”,您應該會看到已使用數據源中的數據填充圖表。
對于編程的數據輸入,您需要編寫一些代碼。本節將向您展示使用編碼輸入構建圖表所需的步驟。
您之前使用圖表編輯器添加的系列在設計時顯示隨機數據。但是,在運行時,除非您手動填充數據,否則系列將沒有數據。從工具箱中選擇一個命令按鈕并將其放在您的表單上。在Visual Basic中雙擊按鈕以訪問代碼編輯器(該方法可能在不同的編程環境中有所不同)。在代碼編輯器中鍵入以下行:
With TChart1.Series(0) .Add 3, "Pears", vbRed .Add 4, "Apples", vbBlue .Add 2, "Oranges", vbGreen End With
運行項目并按下命令按鈕。您的圖表上將顯示三個新欄。 圖表中的第一個系列具有(0)索引,第二個(1)等。因此,在圖表中有多個系列,您可以使用索引選擇要修改的系列。 Series'Add方法接受3個變量,Value,Label和Color。因此,Add方法假設Label軸上的值間隔相等(在本例中為X軸)。如果您的數據包含2個變量,則可以使用AddXY方法。向項目添加另一個Command按鈕并將此代碼放入其中。運行項目并使用以下代碼添加點:
With TChart1.Series(0) If .Count > 0 Then 'Increment X Axis value and add a new random point .AddXY .XValues.Last+(Rnd(100)), (.YValues.Last/.YValues.Last-1)+(Rnd(100)), "", vbBlue Else 'Add a new random point .AddXY 1, (Rnd(100)), "", vbBlue End If End With
最后一個編碼示例生成了新的X和Y值。點之間的X軸距離不是恒定的,這將導致在某些情況下條的重疊,這對于一些但不是所有應用是期望的。使用圖表編輯器更改系列類型(在設計時輸入圖表編輯器并使用第一頁上的“ 更改”按鈕)到LineSeries,顯示另一種以2個變量以圖形方式表示數據的方法。如果您的數據包含2個以上的變量,則還有其他適合顯示數據的系列類型。下表顯示了TeeChart系列類型的組成。
系列類型 |
變量數量 | 數據源屬性 |
Standard |
||
Gantt |
3 |
StartValues, EndValues, AY (Y axis level), AXLabel (Label optionally shown on Y-axis or as mark) |
Line |
2 |
XValues, YValues, XLabel |
Bar |
2 |
XValues, YValues (called Bar), XLabel |
HorizBar |
2 |
XValues, YValues (called Bar), XLabel |
Area |
2 |
XValues, YValues, XLabel |
Point |
2 |
Xvalues, YValues, XLabel |
Pie |
1 |
PieValues, XLabel |
Fast Line |
2 |
XValues, YValues, XLabel |
HorizLine |
2 |
XValues, YValues, YLabel |
HorizArea |
2 |
XValues, YValues, YLabel |
Shape |
4 |
X0 (Top), Y0 (Bottom), X1 (Left), Y1 (Right) |
Bubble |
3 |
XValues, YValues, XLabel, RadiusValues |
3D |
||
Surface |
3 |
XValues, YValues, XLabel, ZValues |
Contour |
3 |
XValues, YValues, XLabel, ZValues |
Waterfall |
3 |
XValues, YValues, XLabel, ZValues |
Color Grid |
3 |
XValues, YValues, XLabel, ZValues |
Vector 3D |
3 |
XValues, YValues, XLabel, ZValues |
Tower |
3 |
XValues, YValues, XLabel, ZValues |
Iso-Surface |
3 |
XValues, YValues, XLabel, ZValues |
Point3D |
3 |
XValues, YValues, XLabel, ZValues |
Bubble |
5 |
XValues, YValues, XLabel, RadiusValues, ZValues |
Triangle Surf. |
3 |
XValues, YValues, XLabel, ZValues |
Polar Grid |
3 |
XValues, YValues, XLabel, (Polar Grid has Sectors, Tracks and Values) |
Extended |
||
Arrow |
4 |
StartXValues, StartYValues, XLabel, EndXValues, EndYValues |
Polar |
2 |
XValues, YValues, Labels (Polar has Angle and Radius) |
Radar |
2 |
XValues, YValues, Labels (Radar has Angle and Radius) |
Polar Bar |
3 |
XValues, YValues, Labels (Polar has Angle and Radius) |
Bezier |
2 |
XValues, YValues, XLabel |
Donut |
2 |
Angle, YValues, Labels |
Smith |
2 |
Resistance, Reactance, Labels |
Pyramid |
2 |
XValues, YValues, XLabels |
Map |
3 |
XValues, YValues, Polygons, Labels |
Org Chart |
2 |
XValues, YValues, Labels |
Tree Map |
2 |
XValues, YValues, Labels |
Financial |
||
Point & Figure |
5 |
OpenValues, CloseValues, HighValues, LowValues, DateValues |
Candle |
5 |
OpenValues, CloseValues, HighValues, LowValues, DateValues |
Volume |
2 |
XValues, YValues (VolumeValues), XLabel |
Darvas |
5 |
OpenValues, CloseValues, HighValues, LowValues, DateValues |
Renko |
2 |
XValues, YValues, Labels |
Kagi |
2 |
XValues, YValues, Labels |
Stats |
||
Histogram |
2 |
XValues, YValues, XLabel |
Horizontal Histogram |
2 |
XValues, YValues, XLabel |
Error Bar |
3 |
XValues, YValues, XLabel, ErrorValues |
Error |
3 |
XValues, YValues, XLabel, StdErrorValues |
High-Low |
3 |
XValues, YValues, LowValues, XLabel |
BoxPlot |
2 |
XValues, SamplesValues, Label |
Horizontal BoxPlot |
2 |
XValues, SamplesValues, Label |
Volume Pipe |
3 |
XValues, YValues, Labels |
Funnel |
3 |
XValues, QuoteValues, OpportunityValues, XLabel |
HighLow Line |
3 |
XValues, HighValues, LowValues, Labels |
Ternary |
5 |
XValues, YValues, ZValues, RadiusValues, WeightingValues, Labels |
Error Point |
6 |
XValues, YValues, LeftError, RightError, TopError, BottomError, Labels |
Error Point 3D |
9 |
XValues, YValues, ZValues, LeftError, RightError, TopError, BottomError, FrontError, BackError, Labels |
Other |
||
Line Point |
2 |
XValues, YValues, XLabel |
Bar Join |
2 |
XValues, YValues, XLabel |
Bar 3D |
3 |
XValues, YValues, YStartPoint, XLabel |
Big Candle |
5 |
OpenValues, CloseValues, HighValues, LowValues, DateValues |
Image Bar |
2 |
XValues, YValues, XLabel |
ImagePoint |
2 |
XValues, YValues, XLabel |
DeltaPoint |
2 |
XValues, YValues, XLabel |
Wind Rose |
2 |
Angle, YValues, Labels |
Clock |
2 |
Angle, YValues, Labels |
Rose |
3 |
Angle, YValues, Angle Values, Labels |
Calender |
2 |
XValues, YValues, Labels |
Tag Cloud |
2 |
YValues, ZValues, Labels |
Gauges |
||
Gauge |
1 |
YValue |
Numerical Gauge |
1 |
YValue |
Linear Gauge |
1 |
YValue |
Vertical |
1 |
YValue |
Circular gauge |
1 |
YValue |
Knob Gauge |
1 |
YValue |
購買TeeChart Pro AciveX正版授權,請點擊“”喲!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn