当前位置: 编程技术>WEB前端
jQuery简单图表peity.js使用示例
来源: 互联网 发布时间:2014-08-25
本文导语: 代码如下: 无标题页 jQuery(function(){ $(".bar-colours-1").peity("bar", { colours: ["red", "green", "blue"],width: 100,height:100 }) $(".bar-colours-2").peity("bar", { colours: function(value) { return value > 0 ? "green" : "red" },width: 100,height:100 }) $(".bar-colours-3").peity("b...
代码如下:
无标题页
jQuery(function(){
$(".bar-colours-1").peity("bar", {
colours: ["red", "green", "blue"],width: 100,height:100
})
$(".bar-colours-2").peity("bar", {
colours: function(value) {
return value > 0 ? "green" : "red"
},width: 100,height:100
})
$(".bar-colours-3").peity("bar", {
colours: function(_, i, all) {
var g = parseInt((i / all.length) * 255)
return "rgb(255, " + g + ", 0)"
},width: 100,height:100
})
$(".pie-colours-1").peity("pie", {
colours: ["cyan", "magenta", "yellow", "black"],diameter:100
})
$(".pie-colours-2").peity("pie", {
colours: function(_, i, all) {
var g = parseInt((i / all.length) * 255)
return "rgb(255, " + g + ", 0)"
},diameter:100
})
var updatingChart = $(".updating-chart").peity("line", { width: 150,height:50})
setInterval(function() {
var random = Math.round(Math.random() * 10)
var values = updatingChart.text().split(",")
values.shift()
values.push(random)
updatingChart
.text(values.join(","))
.change()
}, 1000)
})
5,3,9,6,5,9,7,3,5,2
5,3,2,-1,-3,-2,2,3,5,2
0,-3,-6,-4,-5,-4,-7,-3,-5,-2
4,7,6,5
5,3,9,6,5
5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2