LOGO 首页 OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 技术文档 其他文档  
 
网站管理员

asp无组件生成柱状图、折线图、饼图

admin
2011年4月12日 0:8 本文热度 5360
asp无组件生成柱状图、折线图、饼图 [code] <script> document.write("") var ct1=new ct() function ct(){ this.ac="green,yellow,red,blue,gray".split(",") this.getCss=function(css,k,df){ if(css==null) return def==null ? "" : df var r=new RegExp("(^|)"+k+":([^\;]*)(\;|$)","gi") var a=r.exec(css.replace(/=/g,":").replace(/ /g,"").toLowerCase()) return a==null ? (df==null ? "" : df) : (isNaN(a[2])||a[2]=="" ? a[2] : parseInt(a[2])) } this.bar=function(vList,css){ var l="",a,n,s,hsz,max=0,cx=20,ch var pw=this.getCss(css,"width",500),ph=this.getCss(css,"height",300) if(ph<150||pw<150){ alert("图表区域太小,中断输出!") return } a=vList.split(";") for(var i in a){ a[i]=a[i].split(",") for(var j in a[i]){ if(i>0&&j>0) if(parseInt(a[i][j])>max) max=parseInt(a[i][j]) } } if(max==0) return hsz=(ph-100)/max n=(vList.length-vList.replace(/;/g,"").replace(/,/g,"").length)*20+20 if(pw" l+="" l+="" l+=""+this.getCss(css,"title")+"" l+=""+a[0][0]+"" l+=""+this.getCss(css,"vname")+"" for(i=0;i<5;i++){ l+="" l+=""+(parseInt(max)*(5-i)/5)+"" } for(i in a){ for(j in a[i]){ if(i==0){ if(j>0){ l+="" l+=""+a[i][j]+"" } } else{ if(j==0) l+=""+a[i][j]+"" else{ ch=a[i][j]*hsz l+="" if(this.getCss(css,"showVal")=="t") l+=""+a[i][j]+"" cx+=20 } } } cx+=20 } return l } this.lines=function(vList,css){ var l="",a,n,s,hsz,max=0,ch var pw=this.getCss(css,"width",500),ph=this.getCss(css,"height",300) if(ph<150||pw<150){ alert("图表区域太小,中断输出!") return } a=vList.split(";") for(var i in a){ a[i]=a[i].split(",") for(var j in a[i]){ if(i>0&&j>0) if(parseInt(a[i][j])>max) max=parseInt(a[i][j]) } } if(max==0) return hsz=(ph-100)/max n=a.length*40+40 if(pw" l+="" l+="" l+=""+this.getCss(css,"xname")+"" l+=""+a[0][0]+"" l+=""+this.getCss(css,"title")+"" for(i=0;i<5;i++){ l+="" l+=""+(parseInt(max)*(5-i)/5)+"" } for(i in a){ for(j in a[i]){ if(i==0){ if(j>0){ l+="" l+=""+a[i][j]+"" } } else{ if(j==0) l+=""+a[i][j]+"" else{ ch=a[i][j]*hsz if(i>1){ oh=parseInt(a[i-1][j]*hsz) l+="" } l+="" if(this.getCss(css,"showVal")=="t") l+=""+a[i][j]+"" } } } } return l } this.pie=function(vList,css){ var l="",a,i,j,n,s,amt,dx=0 var pw=this.getCss(css,"width",500),ph=this.getCss(css,"height",300) if(ph<150||pw<150){ alert("图表区域太小,中断输出!") return } a=vList.split(";") n=a.length*170-130 if(pw" l+=""+this.getCss(css,"title")+"" if(a.length==2) dx=pw/2-100 if(a.length==3) dx=pw/2-180 for(i in a){ a[i]=a[i].split(",") amt=0 for(j=1;j0){ l+="" l+=""+a[i][j]+"" } } else{ if(j==0){ l+=""+a[i][j]+"("+amt+")" } else{ ea=a[i][j]*360/amt+sa if(j==a[i].length-1) ea=0 if(a[i][j]>0) l+=this.getPie(60,sa,ea,"title:"+a[i][j]+";val:"+(parseInt((10000*a[i][j]/amt))/100)+"%;x:"+(i*170-70+dx)+";y:"+(ph/2+10)+";background:"+this.ac[j-1]) sa=ea } } } } return l } this.getPie=function(r,sa,ea,css){ var sf,ef,sx,sy,ex,ey var title=this.getCss(css,"title"),val=this.getCss(css,"val") var x=parseInt(this.getCss(css,"x",0)),y=parseInt(this.getCss(css,"y",0)) sf=Math.PI*(sa/180) ef=Math.PI*(ea/180) sy=parseInt(r*Math.sin(sf)) sx=parseInt(r*Math.cos(sf)) ey=parseInt(r*Math.sin(ef)) ex=parseInt(r*Math.cos(ef)) s="m0,0l"+sx+","+sy+"ar-"+r+",-"+r+","+r+","+r+","+ex+","+ey+","+sx+","+sy+",l0,0xe" l="" if(ef==0) ef=270 var cx=(r+10)*Math.cos((sf+ef)/2),cy=(r+10)*Math.sin((sf+ef)/2) l+=""+val+"" return l } this.draw=function(vList,css){ var l,type=this.getCss(css,"type") if(type=="pie") l=this.pie(vList,css) else if(type=="lines") l=this.lines(vList,css) else l=this.bar(vList,css) return l } } </script>
<script> //---柱形图 div1.innerHTML=ct1.draw("季度,东部,中部,北部;1季度,20.4,30.6,90;2季度,27.4,38.6,34.6;3季度,45.9,0,0","type:bar;showVal:t;vname:销售额;title:月统计图") //---线形图 div2.innerHTML=ct1.draw("季度,东部,中部,北部;1季度,20.4,30.6,90;2季度,27.4,38.6,34.6;3季度,45.9,0,0","type:lines;showVal:t;vname:销售额;title:月统计图") //---饼形图 div3.innerHTML=ct1.draw("季度,东部,中部,北部;1季度,20.4,30.6,90;2季度,27.4,38.6,34.6;3季度,45.9,0,0","type:pie;showVal:t;vname:销售额;title:月统计图") </script> [/code]

该文章在 2011/4/12 0:08:52 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2026 ClickSun All Rights Reserved  粤ICP备13012886号-2  粤公网安备44030602007207号