JQuery Highcharts 圖表控件

highcharts是基於javascript的高交互的圖表封裝。目前highcharts可以非常輕鬆的畫出線圖,列圖,餅圖,傳播圖,區域圖等。能兼容主流瀏覽器(包括IE6)。

相關的資料:

Highcharts 官網:http://www.highcharts.com

Highcharts 官網示例:http://www.highcharts.com/demo/

Highcharts 官網文檔:http://www.highcharts.com/documentation/how-to-use

Highcharts 選項參考:http://www.highcharts.com/ref/#chart

以下爲餅狀圖示例:

  1. <html xmlns="http://www.w3.org/1999/xhtml" > 
  2. <head runat="server"> 
  3.     <title>圖表-餅狀</title> 
  4.     <meta http-equiv="Content-Type" content="text/html; charset=iso-utf-8"/> 
  5.     <script type="text/javascript" src="js/jquery-1.5.2.min.js"></script> 
  6.     <script src="js/highcharts.js" type="text/javascript"></script> 
  7.     <script src="JS/exporting.js" type="text/javascript"></script> 
  8.     <style type="text/css"> 
  9.         a:link{ outline: none; text-decoration: none; color: #000;}  
  10.         a:hover{ text-decoration: underline;}  
  11.         a:focus{ outline: 0;}  
  12.         a{ outline: none; text-decoration: none; color: #AAA;}  
  13.     </style> 
  14. </head> 
  15. <body> 
  16.     <form id="form1" runat="server"> 
  17.    <script type="text/javascript"> 
  18.  
  19.        var pieType=1;  
  20.        var chart;  
  21.        $(document).ready(function() {  
  22.            chart = new Highcharts.Chart({  
  23.                chart: {  
  24.                    renderTo: 'container',  
  25.                    defaultSeriesType: 'pie',  
  26.                    plotBackgroundColor: null,  
  27.                    plotBorderWidth: null,  
  28.                    plotShadow: false  
  29.                },  
  30.                title: {  
  31.                 text: 'ITOMS工作量統計'  
  32.                },  
  33.                subtitle: {                           
  34.                     text: '<a href="?t=1">任務單數量</a>&nbsp;&nbsp;<a href="?t=2">計劃工時(小時)</a>&nbsp;&nbsp;<a href="?t=3">實際人數</a>&nbsp;&nbsp;<a href="?t=4">實際工時(小時)</a>'              //圖標的副標題  
  35.                 },  
  36.                tooltip: {  
  37.                    formatter: function() {  
  38.                        return '<b>' + this.point.name + '</b>: ' + this.y + ' %';  
  39.                    }  
  40.                },  
  41.                plotOptions: {  
  42.                    pie: {  
  43.                        allowPointSelect: true,  
  44.                        cursor: 'pointer',  
  45.                        dataLabels: {  
  46.                            enabled: true,  
  47.                            color: '#000000',  
  48.                            connectorColor: '#000000',  
  49.                            formatter: function() {  
  50.                                return '<b>' + this.point.name + '</b>: ' + this.y + ' %';  
  51.                            }  
  52.                        }  
  53.                    }  
  54.                },  
  55.                series: <%=returnValue %> 
  56.                });  
  57.            });  
  58.                   
  59.         </script> 
  60.         <div id="container" style="width: 800px; height: 400px; margin: 0 auto"></div> 
  61.     </form> 
  62. </body> 
  63. </html> 

 

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Web;  
  4. using System.Web.UI;  
  5. using System.Web.UI.WebControls;  
  6.  
  7. namespace Project.Highcharts  
  8. {  
  9.     public partial class Demo_Pie : System.Web.UI.Page  
  10.     {  
  11.         /*public string data = @"[{name: '任務單數量',data: [370.0,162.0,13,13,370.0,162.0,13,13]},   
  12.                                 {name: '計劃工時(小時)',data: [120,23,25,2,370.0,162.0,13,13]},   
  13.                                 {name: '實際人數',data: [60,43,65,20,30.0,12.0,13,103]},   
  14.                                 {name: '實際工時(小時)',data: [89,57,114,26,32,52.0,43,63]}]";  
  15.  
  16.         public string xAxisCategories = "['IT中心部門', '創前萬博考試', '電大服務中心', '考試服務中心','財務部','學生服務中心','職教中心','總經辦']";*/ 
  17.  
  18.         public string returnValue = "";  
  19.         public string returnValue1 = @"[{name: '任務單數量',data: [['IT中心部門', 33.2],{name:'創前萬博考試',y:14.5,sliced:true,selected:true},['電大服務中心',1.2],['考試服務中心', 1.2],['財務部', 33.2],['學生服務中心', 14.5],['職教中心', 1.2],['總經辦', 1.2]]}]";  
  20.         public string returnValue2 = @"[{name: '計劃工時(小時)',data: [['IT中心部門', 16.5],{name:'創前萬博考試',y:3.2,sliced:true,selected:true},['電大服務中心',3.4],['考試服務中心', 0.3],['財務部', 50.8],['學生服務中心', 22.3],['職教中心', 1.8],['總經辦', 1.8]]}]";  
  21.         public string returnValue3 = @"[{name: '實際人數',data: [['IT中心部門', 17.3],{name:'創前萬博考試',y:13.2,sliced:true,selected:true},['電大服務中心',19.9],['考試服務中心', 6.1],['財務部', 9.2],['學生服務中心', 3.7],['職教中心', 4.0],['總經辦', 4.0]]}]";  
  22.         public string returnValue4 = @"[{name: '實際工時(小時)',data: [['IT中心部門', 18.7],{name:'創前萬博考試',y:12.0,sliced:true,selected:true},['電大服務中心',23.9],['考試服務中心', 5.5],['財務部', 6.7],['學生服務中心', 10.9],['職教中心', 9.0],['總經辦', 13.2]]}]";  
  23.           
  24.         protected void Page_Load(object sender, EventArgs e)  
  25.         {  
  26.             int type = Request["t"] != null ? Convert.ToInt32(Request["t"]) : 1;  
  27.             string[] array = new string[] { returnValue1, returnValue2, returnValue3, returnValue4 };  
  28.             returnValue = array[type - 1];  
  29.         }  
  30.     }  
  31. }  

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章