jQuery圓形統計圖實戰開發

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   使用   ar   檔案   

今天我給大家介紹一款圓形統計圖circliful,它基於HTML5的畫布和jQuery,無需使用映像輕鬆實現圓形統計圖,而且有很多屬性設定,使用起來非常方便。

首先我們需要將jquery庫檔案和jquery.circliful.min.js引入到頁面中。

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="js/jquery.circliful.min.js"></script> 

所需的Jquery檔案引入後,現在我們就可以自訂圓形統計圖的基本樣式了:

<style> .circliful {     position: relative;  } .circle-text, .circle-info, .circle-text-half, .circle-info-half {     width: 100%;     position: absolute;     text-align: center;     display: inline-block; } .circle-info, .circle-info-half {     color: #999; } .circliful .fa {     margin: -10px 3px 0 3px;     position: relative;     bottom: 4px; } </style> 

樣式初步定義好之後,只需要在需要統計圖的地方,添加如下樣式代碼:

<div id="myStat" data-dimension="250" data-text="35%" data-info="New Clients"  data-width="30" data-fontsize="38" data-percent="35" data-fgcolor="#61a9dc"  data-bgcolor="#eee" data-fill="#ddd"></div> 

地區塊填寫完之後,我們現在需要初始化它了:

<script> $( document ).ready(function() {         $(‘#myStat‘).circliful();     }); </script> 

 就這麼簡單,只需輕鬆幾部就可以完成帥氣的統計圖了。

下面是外掛程式的基本屬性說明:

Circliful提供了豐富的屬性選項設定,基於html5的data屬性,以下是設定清單。
參數 描述 預設值
data-dimension 圓形圖的寬度和高度px 250
data-text 顯示在圓圈內側的文字內容 empty
data-info 顯示在data-text下的說明資訊 empty
data-width 圓圈的厚度px 15
data-fontsize 圈內文字大小px 15
data-percent 圓圈統計百分比%,1-100 50
data-fgcolor 圓圈的前景色彩 #556b2f
data-bgcolor 圓圈的背景色 #eeeeee
data-fill 圓形的填充背景色 empty
data-type 圓形統計類型,可以是”half”或”full” full
data-total 資料總量,和data-part配合使用 empty
data-part 資料量,與data-total配合使用 empty
data-border 圓形樣式,可以加邊框,如inline或outline empty
data-icon Fontawesome表徵圖樣式,詳情可參照:Fontawesome Website – Icons empty
data-icon-size 表徵圖大小 empty
data-icon-color 表徵圖顏色 empty

jQuery圓形統計圖實戰開發

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.