翻譯|使用教程|編輯:凌霄漢|2022-03-30 15:30:18.133|閱讀 213 次
概述:此次報表開發工具TeeChart Pro .NET使用教程將為大家帶來演示ASP 示例。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
TeeChart Pro 將自動為您定義所有 Axis 標簽,并提供足夠的靈活性來定制您可能有的任何特定要求。 TeeChart Pro 提供真正的多軸。 這些在設計或運行時可用,并為 Axis 定義提供了無數的可能性和靈活性。
在您的服務器上創建一個新的 WebForm 應用程序,并確保它在表單上沒有任何內容的情況下正確運行。
從 Steema ToolBox 選項卡中,選擇一個 WebChart 對象并將其拖過 WebForm。
選擇新的 WebChart1 對象并在“屬性”窗口中導航到 TempChart 屬性并將其從“文件”更改為“會話”。 這意味著由 WebChart 生成的所有臨時圖表都將存儲在會話變量中,而不是臨時文件夾中
為了從會話變量中恢復臨時圖表,我們將添加一個包含一些簡單代碼的新表單。 右鍵單擊您的 ASP.NET 項目并添加一個新的 WebForm,將其命名為 GetChart.aspx。 現在確保 Page_Load 事件如下所示:
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); }
我們現在有一個響應 mouseover 和 mouseclick 事件的交互式圖表。 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 屬性設置為 Script 可以有效地定義您喜歡的任何行為。 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正版價格,歡迎咨詢
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn