本文總結了圖表控件Teechart for .NET經常使用的一些屬性,對圖表開發人員來講是一個很好的參考。html
實現繪圖步驟:web
1.加入Teechart for .NET控件。session
2.建立chart實例並設置相關全局屬性(設置chart實例的屬性將對全部其餘成員,包括全部series實例產生影響)。app
3.添加Series序列實例,設置該實例相關屬性(設置實例化series的屬性做用範圍是該series實例,若是爲單一series實例,可直接設置其屬性而不設置chart實例),並綁定數據源。oop
經常使用屬性:spa
(假設控件實例爲WebChart1,設置全局屬性也可經過實例化chart來設置,即Steema.TeeChart.Chart Chart1 = WebChart1.Chart;在此不考慮這種).net
[html] view plaincopycode
<EMBED id=ZeroClipboardMovie_1 height=18 name=ZeroClipboardMovie_1 type=application/x-shockwave-flash align=middle pluginspage=http://www.macromedia.com/go/getflashplayer width=18 src=http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf wmode="transparent" flashvars="id=1&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false">orm
WebChart1.AutoPostback = false; //自動回發(默認) htm
WebChart1.GetChartFile = "GetChart.aspx"; //處理數據頁(默認),GetChart.aspx內容後附
WebChart1.Width = 400; //顯示寬度
WebChart1.Height = 300; //顯示高度
WebChart1.PictureFormat = Steema.TeeChart.Export.PictureFormats.Bitmap; //顯示圖片的格式,默認PNG
WebChart1.TempChart =Steema.TeeChart.Web.TempChartStyle.Session;
//設置保存數據形式,默認File,通常選session。Chart.Aspect(外觀屬性)
WebChart1.Chart.Aspect.View3D = false; //取消3D表示
Chart.Header(顯示頭)
[html] view plaincopy
<EMBED id=ZeroClipboardMovie_2 height=18 name=ZeroClipboardMovie_2 type=application/x-shockwave-flash align=middle pluginspage=http://www.macromedia.com/go/getflashplayer width=18 src=http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf wmode="transparent" flashvars="id=2&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false">
WebChart1.Chart.Header.Visible = false; //是否顯示頭文字
WebChart1.Chart.Header.Text = "頂部顯示文字";
Chart.Axes(座標軸)
[html] view plaincopy
<EMBED id=ZeroClipboardMovie_3 height=18 name=ZeroClipboardMovie_3 type=application/x-shockwave-flash align=middle pluginspage=http://www.macromedia.com/go/getflashplayer width=18 src=http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf wmode="transparent" flashvars="id=3&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false">
WebChart1.Chart.Axes.Left.Title.Text = "縱座標文字顯示";
WebChart1.Chart.Axes.Bottom.Title.Text = "橫座標文字顯示";
Chart.Legend(圖例)
[html] view plaincopy
<EMBED id=ZeroClipboardMovie_4 height=18 name=ZeroClipboardMovie_4 type=application/x-shockwave-flash align=middle pluginspage=http://www.macromedia.com/go/getflashplayer width=18 src=http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf wmode="transparent" flashvars="id=4&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false">
WebChart1.Chart.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Auto;
//圖例顯示的樣式,包含一下方面:默認auto
WebChart1.Chart.Legend.Alignment=Steema.TeeChart.LegendAlignments.Bottom;
//圖例顯示位置(顯示線條顏色,線條表明對象)
WebChart1.Chart.Legend.Visible = false; //是否顯示圖例
WebChart1.Chart.Legend.Font.Color = System.Drawing.Color.Black;
//圖例文本顯示顏色
<strong>Chart.Panel(底板設置)</strong>
WebChart1.Chart.Panel.Color = System.Drawing.Color.AliceBlue;
//底板顏色(彷佛無論用)
實例化序列:
[html] view plaincopy
<EMBED id=ZeroClipboardMovie_5 height=18 name=ZeroClipboardMovie_5 type=application/x-shockwave-flash align=middle pluginspage=http://www.macromedia.com/go/getflashplayer width=18 src=http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf wmode="transparent" flashvars="id=5&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false">
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line();
WebChart1.Chart.Series.Add(line); //實例化線,也能夠以下一句完成:
Steema.TeeChart.Styles.Line line1 =
new Steema.TeeChart.Styles.Line(WebChart1.Chart);
line1.YValues.DataMember = DS.Tables[0].Columns[2].ToString(); //設置比較刻度(縱座標)
line1.LabelMember = DS.Tables[0].Columns[1].ToString();
//設置成員標籤(橫座標)
line.Title = "111111"; //設置其標題,能夠在圖例上顯示此標題,多線時有用
line.Color = System.Drawing.Color.Red; //設置線條顏色,可不設置,默認
line1.DataSource = DS.Tables[0];
WebChart1.DataBind(); //數據綁定
GetChart.aspx.cs
[html] view plaincopy
<EMBED id=ZeroClipboardMovie_6 height=18 name=ZeroClipboardMovie_6 type=application/x-shockwave-flash align=middle pluginspage=http://www.macromedia.com/go/getflashplayer width=18 src=http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf wmode="transparent" flashvars="id=6&width=18&height=18" allowfullscreen="false" allowscriptaccess="always" bgcolor="#ffffff" quality="best" menu="false" loop="false">
protected void Page_Load(object sender, EventArgs e)
{
string chartName=Request.QueryString["Chart"];
if (Session[chartName]!=null)
{
System.IO.MemoryStream chartStream = new System.IO.MemoryStream();
chartStream=((System.IO.MemoryStream)Session[chartName]);
Response.OutputStream.Write(chartStream.ToArray(),0,(int)chartStream.Length);
chartStream.Close();
Session.Remove(chartName);
}
}