<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var point = new Array();
var x = new Array();
var year = new Array();
var pointx = new Array();
var p1;
function sample() {
for (s = 1; s < 1001;s++ ){
point[s] = 0;
for(sx=1;sx<11;sx++){
if(Math.random()>0.5)point[s]=point[s]+1;
}
}
for(sx=0;sx<11;sx++){
pointx[sx]=0;
}
for(s=1;s<1001;s++){
n = point[s];
pointx[n] = pointx[n] + 1;
}
paint();
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
str=str+sub.rect(0,0,500,500,"blue");
for(s=1;s<11;s++){
str=str+sub.rect(40*s,500-pointx[s],40,pointx[s],"red");
}
str=str+"</svg>";
$("#memo").html(str);
}
</script>
<script>
class svgpaint{
chop(strp){
this.strx="\""+strp+"\"";
return this.strx;
}
rect(x1,y1,w1,h1,col){
this.strx="<rect x="+this.chop(x1)+"\" y="+this.chop(y1)+"\" width="+this.chop(w1);
this.strx=this.strx+"\" height="+this.chop(h1)+" fill="+this.chop(col)+"/>";
return this.strx;
}
text(x1,y1,size,strp){
this.strx="<text x="+this.chop(x1)+" y= "+this.chop(y1)+" font-size="+this.chop(size)+">";
this.strx=this.strx+strp;
this.strx=this.strx+"</text>";
return this.strx;
}
circle(x1,y1,r,col){
this.strx="<circle cx="+this.chop(x1)+"\" cy="+this.chop(y1)+"\" r="+this.chop(r)+" fill="+this.chop(col)+"/>";
return this.strx;
}
line(x1,y1,x2,y2,wide,col){
this.strx="<line x1="+this.chop(x1)+" y1="+this.chop(y1)+" x2="+this.chop(x2)+" y2=";
this.strx=this.strx+this.chop(y2)+"style= \" stroke:"+col+";stroke-width:"+wide+"\"/>";
return this.strx;
}
}
</script>
最終更新:2018年06月17日 04:35