您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > javascriptGraphics
标签:javascript图表奉上源代码,自行研究包括线性图,饼状图,柱形图scriptdocument.write(htmlxmlns:vstylev\\:*{behavior:url(#default#VML)}/style)varct1=newct()functionct(){this.ac=green,yellow,red,blue,gray,purple.split(,)this.getCss=function(css,k,df){if(css==null)returndef==null?:dfvarr=newRegExp((^|)+k+:([^\;]*)(\;|$),gi)vara=r.exec(css.replace(/=/g,:).replace(//g,).toLowerCase())returna==null?(df==null?:df):(isNaN(a[2])||a[2]==?a[2]:parseInt(a[2]))}this.bar=function(vList,css){varl=,a,n,s,hsz,max=0,cx=20,chvarpw=this.getCss(css,width,500),ph=this.getCss(css,height,300)if(ph150||pw150){alert(图表区域太小,中断输出!)return}a=vList.split(;)for(variina){a[i]=a[i].split(,)for(varjina[i]){if(i0&&j0)if(parseInt(a[i][j])max)max=parseInt(a[i][j])}}if(max==0)returnhsz=(ph-100)/maxn=(vList.length-vList.replace(/;/g,).replace(/,/g,).length)*20+20if(pwn)pw=nl+=v:rectfillcolor='+this.getCss(css,background,white)+'style='position:absolute;left:0;top:0;width:+pw+;height:+ph+'v:shadowon=ttype=embossopacity=80%offset='3px,3px'offset2='5px,5px'//v:rectl+=v:linefrom=+30+,+(ph-30)+to=+30+,+10+v:strokestartarrow=noneendarrow=classic//v:linel+=v:linefrom=+30+,+(ph-30)+to=+(pw-10)+,+(ph-30)+v:strokestartarrow=noneendarrow=classic//v:linel+=spanstyle='position:absolute;z-index:3;font:12;left:220;top:10'+this.getCss(css,title)+/spanl+=spanstyle='position:absolute;z-index:3;font:12;left:+(pw-50)+;top:+(ph-20)+'+a[0][0]+/spanl+=spanstyle='position:absolute;z-index:3;font:12;left:10;top:10;width:5;word-break:break-all'+this.getCss(css,vname)+/spanfor(i=0;i5;i++){l+=v:linefrom=+30+,+(70+i*(ph-100)/5)+to=+(pw-10)+,+(70+i*(ph-100)/5)+strokecolor=#c0c0c0v:strokedashstyle=dash//v:linel+=spanstyle='position:absolute;z-index:3;font:12;left:+10+;top:+(65+i*(ph-100)/5)+'+(parseInt(max)*(5-i)/5)+/span}for(iina){for(jina[i]){if(i==0){if(j0){l+=v:rectfillcolor='+this.ac[j-1]+'style='position:absolute;left:+(j*80-20)+;top:30;width:20;height:20'/l+=spanstyle='position:absolute;z-index:3;font:12;left:+(j*80+5)+;top:35'+a[i][j]+/span}}else{if(j==0)l+=spanstyle='position:absolute;z-index:3;font:12;left:+cx+;top:+(ph-25)+'+a[i][j]+/spanelse{ch=a[i][j]*hszl+=v:recttitle='+a[i][j]+'fillcolor='+this.ac[j-1]+'style='position:absolute;left:+cx+;top:+(ph-30-ch)+;width:20;height:+ch+'/if(this.getCss(css,showVal)==t)l+=spanstyle='position:absolute;z-index:3;font:12;left:+(cx+3)+;top:+(ph-42-ch)+'+a[i][j]+/spancx+=20}}}cx+=20}returnl}this.lines=function(vList,css){varl=,a,n,s,hsz,max=0,chvarpw=this.getCss(css,width,500),ph=this.getCss(css,height,300)if(ph150||pw150){alert(图表区域太小,中断输出!)return}a=vList.split(;)for(variina){a[i]=a[i].split(,)for(varjina[i]){if(i0&&j0)if(parseInt(a[i][j])max)max=parseInt(a[i][j])}}if(max==0)returnhsz=(ph-100)/maxn=a.length*40+40if(pwn)pw=nl+=v:rectfillcolor='+this.getCss(css,background,white)+'style='position:absolute;left:0;top:0;width:+pw+;height:+ph+'v:shadowon=ttype=embossopacity=80%offset='3px,3px'offset2='5px,5px'//v:rectl+=v:linefrom=+30+,+(ph-30)+to=+30+,+10+v:strokestartarrow=noneendarrow=classic//v:linel+=v:linefrom=+30+,+(ph-30)+to=+(pw-10)+,+(ph-30)+v:strokestartarrow=noneendarrow=classic//v:linel+=spanstyle='position:absolute;z-index:3;font:12;left:+(pw-50)+;top:+(ph-20)+'+this.getCss(css,xname)+/spanl+=spanstyle='position:absolute;z-index:3;font:12;left:10;top:10;width:5;word-break:break-all'+a[0][0]+/spanl+=spanstyle='position:absolute;z-index:3;font:12;left:220;top:10'+this.getCss(css,title)+/spanfor(i=0;i5;i++){l+=v:linefrom=+30+,+(70+i*(ph-100)/5)+to=+(pw-10)+,+(70+i*(ph-100)/5)+strokecolor=#c0c0c0v:strokedashstyle=dash//v:linel+=spanstyle='position:absolute;z-index:3;font:12;left:+10+;top:+(65+i*(ph-100)/5)+'+(parseInt(max)*(5-i)/5)+/span}for(iina){for(jina[i]){if(i==0){if(j0){l+=v:rectfillcolor='+this.ac[j-1]+'style='position:absolute;left:+(j*80-20)+;top:30;width:20;height:20'/l+=spanstyle='position:absolute;z-index:3;font:12;left:+(j*80+5)+;top:35'+a[i][j]+/span}}else{if(j==0)l+=spanstyle='position:absolute;z-index:3;font:12;left:+(i*40)+;top:+(ph-25)+'+a[i][j]+/spanelse{ch=a[i][j]*hszif(i1){oh=parseInt(a[i-1][j]*hsz)l+=v:linefrom=+((i-1)*40)+,+(ph-oh-30)+to=+(i*40)+,+(ph-ch-30)+strokecolor='+this.ac[j-1]+'/}l+=v:recttitle='+a[i][j]+'fillcolor='+this.ac[j-1]+'style='z-index:3;position:absolute;left:+(i*40-1)+;top:+(ph-ch-31)+;width:3;height:+3+'/if(this.getCss(css,showVal)==t)l+=spanstyle='position:absolute;z-index:3;font:12;left:+(i*40-5)+;top:+(ph-ch-42)+'+a[i][j]+/span}}}}returnl}this.pie=function(vList,css){varl=,a,i,j,n,s,amt,dx=0varpw=this.getCss(css,width,500),ph=this.getCss(css,height,300)if(ph150||pw150){alert(图表区域太小,中断输出!)return}a=vList.split(;)n=a.length*170-130if(pwn)pw=nl+=v:rectfillcolor='+this.getCss(css,background,white)+'style='position:absolute;left:0;top:0;width:+pw+;height:+ph+'v:shadowon=ttype=embossopacity=80%offset='3px,3px'offset2='5px,5px'//v:rectl+=spanstyle='position:absolute
本文标题:javascriptGraphics
链接地址:https://www.777doc.com/doc-5536314 .html