翻譯|使用教程|編輯:凌霄漢|2022-03-30 15:30:18.133|閱讀 231 次
概述:此次報(bào)表開(kāi)發(fā)工具TeeChart Pro .NET使用教程將為大家?guī)?lái)演示ASP 示例。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
TeeChart Pro 將自動(dòng)為您定義所有 Axis 標(biāo)簽,并提供足夠的靈活性來(lái)定制您可能有的任何特定要求。 TeeChart Pro 提供真正的多軸。 這些在設(shè)計(jì)或運(yùn)行時(shí)可用,并為 Axis 定義提供了無(wú)數(shù)的可能性和靈活性。
在您的服務(wù)器上創(chuàng)建一個(gè)新的 WebForm 應(yīng)用程序,并確保它在表單上沒(méi)有任何內(nèi)容的情況下正確運(yùn)行。
從 Steema ToolBox 選項(xiàng)卡中,選擇一個(gè) WebChart 對(duì)象并將其拖過(guò) WebForm。
選擇新的 WebChart1 對(duì)象并在“屬性”窗口中導(dǎo)航到 TempChart 屬性并將其從“文件”更改為“會(huì)話”。 這意味著由 WebChart 生成的所有臨時(shí)圖表都將存儲(chǔ)在會(huì)話變量中,而不是臨時(shí)文件夾中
為了從會(huì)話變量中恢復(fù)臨時(shí)圖表,我們將添加一個(gè)包含一些簡(jiǎn)單代碼的新表單。 右鍵單擊您的 ASP.NET 項(xiàng)目并添加一個(gè)新的 WebForm,將其命名為 GetChart.aspx。 現(xiàn)在確保 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);              
    }  
} 
現(xiàn)在我們可以繼續(xù)制作一些基本的 HotSpot 功能; 在我們?cè)瓉?lái)的 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; 
} 
執(zhí)行此代碼并將鼠標(biāo)移到氣泡上將顯示系列標(biāo)記的值,在本例中為 YValues。
要為圖表添加縮放功能,我們需要做的就是添加一個(gè)縮放工具和一些簡(jiǎn)單的代碼來(lái)控制縮放狀態(tài):
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); 
} 
我們現(xiàn)在有一個(gè)響應(yīng) mouseover 和 mouseclick 事件的交互式圖表。 SeriesHotSpot,在這種情況下與氣泡系列相關(guān)聯(lián),當(dāng)鼠標(biāo)移到它上面時(shí),將顯示系列標(biāo)記的值。 但是,通過(guò) MapAction 屬性,我們可以自定義鼠標(biāo)移到 SeriesHotSpot 上時(shí)的行為。 例如,我們可能希望單擊其中一個(gè)氣泡以將我們帶到指定的 URL; 這完全可以通過(guò)將 MapAction 屬性設(shè)置為 URL、鏈接 SeriesHotSpot 事件并在其中指定 URL 來(lái)實(shí)現(xiàn):
在 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 屬性設(shè)置為 Script 可以有效地定義您喜歡的任何行為。 TeeChart 為您提供了一些有用的內(nèi)置腳本,可以通過(guò) HelperScripts 枚舉調(diào)用。 例如,要在鼠標(biāo)懸停在氣泡系列點(diǎn)之一上時(shí)打開(kāi)圖像文件,我們將添加以下代碼:
在 Page_Load 事件中:
seriesHotSpot1.MapAction = Steema.TeeChart.Styles.MapAction.Script; seriesHotSpot1.HelperScript = Steema.TeeChart.Tools.HotspotHelperScripts.Annotation;
此處的第二行確保將相關(guān)的 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>"); 
} 
要進(jìn)一步自定義行為,只需設(shè)計(jì)您自己的 JavaScript 例程,將它們添加到客戶端瀏覽器,然后通過(guò)將它們及其參數(shù)添加到 e.PointPolygon.Attributes 來(lái)調(diào)用它們。
如果您想了解TeeChart for .NET正版價(jià)格,歡迎咨詢
 
 
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn