翻譯|使用教程|編輯:楊鵬連|2021-07-20 11:31:55.607|閱讀 348 次
概述:本文介紹TeeChart圖表ASP.NET網絡表格實例 ,及如何創建一個動態的WebChart 。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
TeeChart for .NET是優秀的 4.0 WinForm 圖表控件,官方獨家授權漢化,集功能全面、性能穩定版、優惠等優勢。NET 的 TeeChart for .NET 中文承諾讓您在使用和學習上沒有語言障礙,最少可以節省 30% 的開發時間。
網絡表格實例
請參閱與TeeChart一起安裝的TeeChartForNET虛擬共享,了解WebForm的工作實例以及用C#.NET和VB.NET編寫的其他ASP.NET實例。
網絡表格實例
如何創建一個動態的WebChart
private void Page_Load(object sender, System.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); } }現在我們可以繼續制作一些基本的HotSpot功能;在我們原始WebForm的Form_Load事件中,我們可以添加類似以下的代碼。
private void Page_Load(object sender, System.EventArgs e) { //Let's work with the Chart object for convenience Steema.TeeChart.Chart Chart1 = WebChart1.Chart; //Add in a series and fill it Chart1.Aspect.View3D = false; Steema.TeeChart.Styles.Bubble bubble1 = new Steema.TeeChart.Styles.Bubble(Chart1); bubble1.FillSampleValues(); //Add a SeriesToolTip to the Chart Steema.TeeChart.Tools.SeriesHotspot seriesHotSpot1 = new Steema.TeeChart.Tools.SeriesHotspot(Chart1); //Steema.TeeChart.Styles.MapAction.Mark is the default value seriesHotSpot1.MapAction = Steema.TeeChart.Styles.MapAction.Mark; }執行這段代碼并將鼠標移到氣泡上,將顯示系列標記的值,在本例中是YValues。
private void Page_Load(object sender, System.EventArgs e) { //Let's work with the Chart object for convenience Steema.TeeChart.Chart Chart1 = WebChart1.Chart; //Add in a series and fill it Chart1.Aspect.View3D = false; Steema.TeeChart.Styles.Bubble bubble1 = new Steema.TeeChart.Styles.Bubble(Chart1); bubble1.FillSampleValues(); //Add a SeriesToolTip to the Chart Steema.TeeChart.Tools.SeriesHotspot seriesHotSpot1 = new Steema.TeeChart.Tools.SeriesHotspot(Chart1); //Steema.TeeChart.Styles.MapAction.Mark is the default value seriesHotSpot1.MapAction = Steema.TeeChart.Styles.MapAction.Mark; //Add a ZoomTool to the Chart Steema.TeeChart.Tools.ZoomTool zoomTool1 = new Steema.TeeChart.Tools.ZoomTool(Chart1); // *************** Code for zoom support *************** //check whether zoom request is being sent CheckZoom(WebChart1); } private void CheckZoom(WebChart wChart) { ArrayList zoomedState=(ArrayList)Session[wChart.ID+"Zoomed"]; zoomedState=((Steema.TeeChart.Tools.ZoomTool)wChart.Chart.Tools[0]).SetCurrentZoom(Request,zoomedState); if (zoomedState==null) Session.Remove(wChart.ID+"Zoomed"); else Session.Add(wChart.ID+"Zoomed",zoomedState); }我們現在有了一個交互式圖表,它對鼠標懸停和鼠標點擊事件做出反應。SeriesHotSpot,在這種情況下與一個氣泡系列相關聯,當鼠標移到它上面時,將顯示系列標記的值。然而,通過MapAction屬性,我們可以自定義SeriesHotSpot在鼠標移動到它上面時的行為。例如,我們可能希望點擊其中一個氣泡,將我們帶到一個指定的URL;這完全可以通過將MapAction屬性設置為URL,鏈接SeriesHotSpot事件并在其中指定URL。
在Page_Load事件中。
seriesHotSpot1.MapAction = Steema.TeeChart.Styles.MapAction.URL; seriesHotSpot1.GetHTMLMap += new Steema.TeeChart.Tools.SeriesHotspotEventHandler(seriesHotSpot1_GetHTMLMap);還有GetHTMLMap方法。
private void seriesHotSpot1_GetHTMLMap(Steema.TeeChart.Tools.SeriesHotspot sender, Steema.TeeChart.Tools.SeriesHotspotEventArgs e) { e.PointPolygon.Title = "Go to the Steema web"; e.PointPolygon.; e.PointPolygon.Attributes = "target='_blank'"; }將MapAction屬性設置為腳本可以有效地讓你定義任何你喜歡的行為。TeeChart為你提供了一些有用的內置腳本,可以通過HelperScripts枚舉調用。例如,當鼠標在一個氣泡系列點上時,要打開一個圖像文件,我們可以添加以下代碼。
在Page_Load事件中。
seriesHotSpot1.MapAction = Steema.TeeChart.Styles.MapAction.Script; seriesHotSpot1.HelperScript = Steema.TeeChart.Tools.HotspotHelperScripts.Annotation;這里的第二行確保相關的JavaScript被添加到客戶端瀏覽器中。
還有GetHTMLMap方法。
private void seriesHotSpot1_GetHTMLMap(Steema.TeeChart.Tools.SeriesHotspot sender, Steema.TeeChart.Tools.SeriesHotspotEventArgs e) { e.PointPolygon.Attributes=String.Format(Steema.TeeChart.Texts.HelperScriptAnnotation, "<IMG SRC=Images/myimage.jpg>"); }要進一步定制行為,只需要設計你自己的JavaScript例程,將它們添加到客戶端瀏覽器,然后通過將它們和它們的參數添加到e.PointPolygon.Attributes來調用它們。
現TeeChart for .NET已加入在線訂購,現在搶購可立享優惠!
如果您對該圖表控件感興趣,歡迎加入圖表控件QQ交流群:740060302
關注慧聚IT微信公眾號???,了解產品的最新動態及最新資訊。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: