这是方法var bar = function (id,title,data){ //展示的id this.id = ''; //标题 this.title = ''; //数据 this.data = ''; //宽 this.width = 500; //背景图片位置 this.bgimg = 'images/plan.gif'; //动画速度 this.speed = 1000; //投票总数 var num_all = 0; this.show = function (){ //添加一个table对象 $("#"+this.id).append("") $("#"+this.id+" table").append(""+this.title+"") //计算总数 $(this.data).each(function(i,n){ num_all += parseInt(n[1]); }) var that = this; //起始 var s_img = [0,-52,-104,-156,-208]; //中间点起始坐标 var c_img = [-312,-339,-367,-395,-420]; //结束 var e_img = [-26,-78,-130,-182,-234]; var that = this; var div; $(this.data).each(function(i,n){ //计算比例 var bili = (n[1]*100/num_all).toFixed(2); //计算图片长度, *0.96是为了给前后图片留空间 var img = parseFloat(bili)*0.96; if(img>0) { div = ""; } else { div=''; } $("#"+that.id+" table").append(""+n[0]+":"+div+""+n[1]+"("+bili+"%)") }) this.play(); } this.play = function (){ var that = this; $("#"+this.id+" div").each(function(i,n){ if($(n).attr('fag')) { $(n).animate( { width: $(n).attr('fag')+'%'}, that.speed ) } }) }}调用
文件目录······
暂无数据
猜你喜欢
更多»
项目推荐
更多»
PDF电子书
更多»
Java多线程编程核心技术
(2)
Linux命令详解词典.pdf
(5)
深入Python3中文版
(0)
百度SEO一本通.pdf
(0)
mysql必知必会.pdf
(2)
疯狂JAVA讲义 pdf电子书
(3)
C# 图解教程pdf电子书
(3)
研磨设计模式 pdf电子书
(0)