圖例設(shè)計
TChart Series類是所有Series類型的共同原型。當(dāng)使用TeeChart在線幫助獲取關(guān)于任何系列類型的幫助時,請遵循位于繼承類型列表中的系列類的鏈接,然后單擊系列成員,其中將包含所有繼承屬性和方法的列表。
加入官方社群740060302,歡迎相互交流
系列類結(jié)構(gòu)
作為對TeeChart類型庫結(jié)構(gòu)的一點背景知識,這里是對Series類和接口的解釋。下圖顯示了TeeChart系列類之間的關(guān)系。所有類都派生自泛型“Series”類,因此共享“Series”屬性和方法。幾個抽象類派生自系列(Custom3DSeries, CustomBarSeries和CircledSeries),這些是灰色突出顯示的,它們的接口不能直接用于編程,它們的特征由它們的衍生系列類型繼承。所有衍生系列(橙色)都可以在TeeChart畫廊中訪問,以便包含在您的圖表中。以這種方式派生的TeeChart系列允許通過公共索引結(jié)構(gòu)對繼承的屬性和方法進行可編程訪問(請參閱本節(jié)后面的示例代碼)。
		 
 
	
使用TChart編輯器在設(shè)計時添加系列更容易,但您也可以在運行時為相同的TChart創(chuàng)建和添加新的和不同的系列類型。
所有AreaSeries屬性和方法都可用于新系列,就像在設(shè)計時創(chuàng)建的任何系列一樣。
在同一圖表中混合不同系列類的一個例子是,在設(shè)計時使用TeeChart編輯器向圖表添加區(qū)域(系列(0))、條形(系列(1))和線條(系列(2))系列。所有這些都訪問一個共同的索引結(jié)構(gòu),即圖表的系列列表。要使用該系列,可能如下所示:
[C#]
//Add a series at runtime
private void button1_Click(object sender, System.EventArgs e)
{
Steema.TeeChart.Styles.Area tmpAreaSeries = new Steema.TeeChart.Styles.Area(tChart1.Chart);
tmpAreaSeries.FillSampleValues(4);
//Or
//Steema.TeeChart.Styles.Area tmpAreaSeries = new Steema.TeeChart.Styles.Area();
//tChart1.Series.Add(tmpAreaSeries);
//tmpAreaSeries.FillSampleValues(4);
}
	點擊復(fù)制
[VB.Net]
'Add a series at runtime Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tmpAreaSeries As New Steema.TeeChart.Styles.Area(TChart1.Chart) tmpAreaSeries.FillSampleValues(4) 'Or 'Dim tmpAreaSeries As New Steema.TeeChart.Styles.Area() 'TChart1.Series.Add(tmpAreaSeries) 'tmpAreaSeries.FillSampleValues(4) End Sub
點擊復(fù)制
選擇串聯(lián)類型
為圖表選擇系列類型在很大程度上取決于您自己對圖表的要求。然而,在某些情況下,由于要繪制的變量的數(shù)量,圖表的選擇可能取決于哪些系列類型支持輸入變量的數(shù)量。下表顯示了每種系列類型允許的變量數(shù)量。
	
標(biāo)記可用于擴展2變量系列類型的值。請參閱下面的示例,該示例在同一圖表中使用了3個條形系列類型的實例。
例子:
使用Bar系列類型
	 
以最簡單的形式,數(shù)據(jù)產(chǎn)生以下圖表,按月分組信息:
	 
 
代碼:
[C#]
foreach(Steema.TeeChart.Styles.Series tSeries in tChart1.Series)
{tSeries.Marks.Visible = false;}
tChart1.Header.Text = "Production results";
bar1.Add(300,"Jan");
bar1.Add(325,"Feb");
bar1.Add(287,"Mar");
bar1.Title = "Product10";
bar2.Add(175,"Jan");
bar2.Add(223,"Feb");
bar2.Add(241,"Mar");
bar2.Title = "Product12";
bar3.Add(461,"Jan");
bar3.Add(470,"Feb");
bar3.Add(455,"Mar");
bar3.Title = "Product14";
	點擊復(fù)制
[VB.Net]
Dim TSeries As Steema.TeeChart.Styles.Series For Each TSeries In TChart1.Series TSeries.Marks.Visible = False Next TChart1.Header.Text = "Production results" Bar1.Add(300, "Jan") Bar1.Add(325, "Feb") Bar1.Add(287, "Mar") Bar1.Title = "Product10" Bar2.Add(175, "Jan") Bar2.Add(223, "Feb") Bar2.Add(241, "Mar") Bar2.Title = "Product12" Bar3.Add(461, "Jan") Bar3.Add(470, "Feb") Bar3.Add(455, "Mar") Bar3.Title = "Product14"
點擊復(fù)制
或者(按產(chǎn)品分組):
	 
 
代碼:
	[C#]
foreach(Steema.TeeChart.Styles.Series tSeries in tChart1.Series)
foreach(Steema.TeeChart.Styles.Series tSeries in tChart1.Series)
{tSeries.Marks.Visible = false;}
tChart1.Header.Text = "Production results";
bar1.Add(300,"Product10");
bar1.Add(175,"Product12");
bar1.Add(461,"Product14");
bar1.Title = "Jan";
bar2.Add(325,"Product10");
bar2.Add(223,"Product12");
bar2.Add(470,"Product14");
bar2.Title = "Feb";
bar3.Add(287,"Product10");
bar3.Add(241,"Product12");
bar3.Add(455,"Product14");
bar3.Title = "Mar";
	點擊復(fù)制
[VB.Net]
Dim TSeries As Steema.TeeChart.Styles.Series For Each TSeries In TChart1.Series TSeries.Marks.Visible = False Next TChart1.Header.Text = "Production results" Bar1.Add(300, "Product10") Bar1.Add(175, "Product12") Bar1.Add(461, "Product14") Bar1.Title = "Jan" Bar2.Add(325, "Product10") Bar2.Add(223, "Product12") Bar2.Add(470, "Product14") Bar2.Title = "Feb" Bar3.Add(287, "Product10") Bar3.Add(241, "Product12") Bar3.Add(455, "Product14") Bar3.Title = "Mar"
點擊復(fù)制
我們在上面的表中添加了新的值(stock):
	 
表中的庫存值通常高于月產(chǎn)量,因此顯示它們會得到下圖(這次是2D)。該圖表使用線系列來區(qū)分股票。
	 
 
將以下代碼添加到前面示例的第一個代碼中:
[C#]
line1.Add(600,"Jan"); line1.Add(715,"Feb"); line1.Add(676,"Mar"); line1.Title = "Product10 Stock"; line1.Color = bar1.Color; line2.Add(245,"Jan"); line2.Add(270,"Feb"); line2.Add(315,"Mar"); line2.Title = "Product10 Stock"; line2.Color = bar2.Color; line3.Add(800,"Jan"); line3.Add(755,"Feb"); line3.Add(835,"Mar"); line3.Title = "Product10 Stock"; line3.Color = bar3.Color;
點擊復(fù)制
[VB.Net]
Line1.Add(600, "Jan") Line1.Add(715, "Feb") Line1.Add(676, "Mar") Line1.Title = "Product10 Stock" Line1.Color = Bar1.Color Line2.Add(245, "Jan") Line2.Add(270, "Feb") Line2.Add(315, "Mar") Line2.Title = "Product10 Stock" Line2.Color = Bar2.Color Line3.Add(800, "Jan") Line3.Add(755, "Feb") Line3.Add(835, "Mar") Line3.Title = "Product10 Stock" Line3.Color = Bar3.Color
點擊復(fù)制
向系列添加數(shù)據(jù)
大多數(shù)系列類型(other than ADO.NET datasources Tutorial 8 and Functions Tutorial 7除外)使用Add方法的24個泛型重載來添加數(shù)據(jù)。
也有一些例外,見下表:
	請注意,除了ShapeSeries之外,所有系列特定的Add方法都是作為進一步的重載自動添加到通用的Add方法中,因此可以從那里訪問(例如candleSeries1)。添加(NewDateTime(27) 2002年,11日,100400200300);)。 
添加點時,可以手動為點添加顏色
例子:
[C#]
bar1.Add(50,"Tomatoes",Color.Tomato);
點擊復(fù)制
[VB.Net]
Bar1.Add(50, "Tomatoes", Color.Tomato)
點擊復(fù)制
	或者,您可以允許TeeChart分配顏色。TeeChart將為每個新系列或每個新系列點選擇最多19種獨特且尚未使用的顏色之一。ColorEach = True。
例子:
[C#]
Random rnd = new Random();
bar1.ColorEach = true;
for(int i = 0; i < 19; ++i)
{
int higher = i + 65;
char letter = (char) higher;
bar1.Add(rnd.Next(100),letter.ToString());
}
	點擊復(fù)制
[VB.Net]
Dim i As Integer Bar1.ColorEach = True For i = 0 To 19 Bar1.Add(Rnd() * 100, Chr(i + 65)) Next
點擊復(fù)制
	可以在點上添加透明顏色,以便為ValueList中的值保留空間,而不顯示在圖表上。
例子:
	[C#]
bar1.Add(45, "My Transparent Bar", Color.Transparent);
bar1.Add(45, "My Transparent Bar", Color.Transparent);
點擊復(fù)制
[VB.Net]
Bar1.Add(45, "My Transparent Bar", Color.Transparent)
點擊復(fù)制
從序列中刪除數(shù)據(jù)點
Use Series.Delete to delete a point from a Series. Series.Delete有兩個重載:
- 
		public Void Delete(System.Int32) 
 刪除序列中的第n個點。
- 
		public Void Delete(System. Int32, System.Int32) 
 從序列中的第n個點開始刪除若干點n。
例子:
[C#]
bar1.Delete(7,2); (deletes two points starting from the 8th Series point (index starts at zero))
點擊復(fù)制
[VB.Net]
Bar1.Delete(7, 2) (deletes two points starting from the 8th Series point (index starts at zero))
點擊復(fù)制
向序列添加空點
Series.Add 有三個重載,允許你添加一個Null點到一個系列:
- 
		添加一個新的空點。 
public Int32 Add()
- 
		添加帶有指定文本的新的空點。 
public Int32 Add(System.String)
- 
		在具有指定文本的指定x值處添加新的空點 
public Int32 Add(System.Double, System.String)
	上面的第二個重載將向Series添加一個Null點,允許您為該點定義一個標(biāo)簽,但在該點的Series中留下一個斷點。在Line Series的情況下,斷點前的最后一個點不會與斷點后的第一個點連接。
例子:
	[C#]
line1.Add("Null Point");
line1.Add("Null Point");
	點擊復(fù)制
Line1.Add("Null Point")
	點擊復(fù)制
請在TeeChart幫助文件中查找其他兩個重載的使用示例。
如需下載產(chǎn)品TeeChart for NET ,請點擊產(chǎn)品名進入下載頁面

 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網(wǎng)安備
            50010702500608號
渝公網(wǎng)安備
            50010702500608號
             
            
 客服熱線
客服熱線