<img src="http://files.jb51.net/file_images/article/201405/20140502140729.gif?20144214754" alt="jQuery简单图表peity.js使用示例_jquery" ><br><div class="codetitle"> <span><a style="CURSOR: pointer" data="83774" class="copybut" id="copybut83774" onclick="doCopy('code83774')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code83774"> <br> <br> <br><title>无标题页</title> <br><script type="text/javascript" src="jQuery.js"></script> <br><script type="text/javascript" src="jquery.peity.js"></script> <br><script type="text/javascript"> <BR>jQuery(function(){ <BR>$(".bar-colours-1").peity("bar", { <BR>colours: ["red", "green", "blue"],width: 100,height:100 <BR>}) <BR>$(".bar-colours-2").peity("bar", { <BR>colours: function(value) { <BR>return value > 0 ? "green" : "red" <BR>},width: 100,height:100 <BR>}) <BR>$(".bar-colours-3").peity("bar", { <BR>colours: function(_, i, all) { <BR>var g = parseInt((i / all.length) * 255) <BR>return "rgb(255, " + g + ", 0)" <BR>},width: 100,height:100 <BR>}) <BR>$(".pie-colours-1").peity("pie", { <BR>colours: ["cyan", "magenta", "yellow", "black"],diameter:100 <BR>}) <BR>$(".pie-colours-2").peity("pie", { <BR>colours: function(_, i, all) { <BR>var g = parseInt((i / all.length) * 255) <BR>return "rgb(255, " + g + ", 0)" <BR>},diameter:100 <BR>}) <br><br><BR>var updatingChart = $(".updating-chart").peity("line", { width: 150,height:50}) <BR>setInterval(function() { <BR>var random = Math.round(Math.random() * 10) <BR>var values = updatingChart.text().split(",") <BR>values.shift() <BR>values.push(random) <BR>updatingChart <BR>.text(values.join(",")) <BR>.change() <BR>}, 1000) <BR>}) <BR></script> <br> <br> <br><span class="bar-colours-1">5,3,9,6,5,9,7,3,5,2</span> <br><span class="bar-colours-2">5,3,2,-1,-3,-2,2,3,5,2</span> <br><span class="bar-colours-3">0,-3,-6,-4,-5,-4,-7,-3,-5,-2</span> <br><br> <br><span class="pie-colours-1">4,7,6,5</span> <br><span class="pie-colours-2">5,3,9,6,5</span> <br><br> <br><span class="updating-chart">5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2</span> <br> <br> <br> </div>