JAVASCRIPT绘制曲线 圆形饼图实例

更新时间:2023-05-15 01:06:57 阅读: 评论:0

<html>
<head>
<title>JavaScript绘制曲线、圆形饼图实例</title>
<script language="JavaScript">
IE4=!(navigator.appVersion.charAt(0)<"4"||navigator.appName=="Netscape") var xo=0
var yo=0
var Ox=-1
var Oy=-1
var rad=Math.PI/180
var maxY=400
var color="red"
function print(str){
document.write(str)
}
function orgY(y){
return maxY-y
}
function outPlot(x,y,w,h){
print('<span
></span>')
}
function Plot(x,y){
outPlot(x,y,1,1)
if(Ox>=0||Oy>=0){
ShowLine(Ox,Oy,x-Ox,y-Oy)
}
Ox=x
Oy=y
}
function ShowLine(x,y,w,h){
if(w<0){
x+=w
w=Math.abs(w)
}
if(h<0){
y+=h
h=Math.abs(h)
}
if(w<1)w=1
if(h<1)h=1
outPlot(x,und(w),und(h))
}
function LineTo(x,y){
Line(xo,yo,x,y)
}
function sign(n){
if(n>0)
return1
if(n<0)
return-1
return n
}
function Line(x1,y1,x2,y2){ und(x2)
und(y2)
xo=x2
yo=y2
y1=orgY(y1)
y2=orgY(y2)
var str=""
var i=0
var x=x1
var y=y1
dx=Math.abs(x2-x1)
dy=Math.abs(y2-y1)
s1=sign(x2-x1)
s2=sign(y2-y1)
if(dx==0||dy==0){ ShowLine(x1,y1,x2-x1,y2-y1) return
}
if(dx>dy){
temp=dx
dx=dy
dy=temp
key=1
}el
创业成功的秘诀key=0
e=2*dy-dx
for(i=0;i<dx;i++){
做蛋糕的方法和步骤px=0
py=0
Plot(x,y)
while(e>=0){
if(key==1){
x+=s1
px+=s1
}el{
y+=s2
py+=s2
}
e=e-2*dx
}
if(key==1)重口小说
y+=s2
el
x+=s1
e=e+2*dy
}
}
function MoveTo(x,y){
Ox=Oy=-1
und(x)
und(y)
}
//圆
function Cir(x,y,r){
MoveTo(x+r,y)
for(i=0;i<=360;i+=5){
LineTo(s(i*rad)+x,r*Math.sin(i*rad)+y) }
}
//弧形
function Arc(x,y,r,a1,a2){
MoveTo(s(a1*rad)+x,r*Math.sin(a1*rad)+y) for(i=a1;i<=a2;i++){
LineTo(s(i*rad)+x,r*Math.sin(i*rad)+y) }
}
//扇形
function Pei(x,y,r,a1,a2){
MoveTo(x,y)
for(var i=a1;i<=a2;i++){
LineTo(s(i*rad)+x,r*Math.sin(i*rad)+y) }
LineTo(x,y)
}
//弹出扇形
function PopPei(x,y,r,a1,a2){
dx=s((a1+(a2-a1)/2)*rad)/10
dy=r*Math.sin((a1+(a2-a1)/2)*rad)/10
x+=dx
y+=dy
MoveTo(x,y)
for(var i=a1;i<=a2;i++){
LineTo(s(i*rad)+x,r*Math.sin(i*rad)+y) }
LineTo(x,y)
}
//矩形
function Rect(x,y,w,h){
MoveTo(x,y)
LineTo(x+w,y)
LineTo(x+w,y+h)
LineTo(x,y+h)
LineTo(x,y)
}
//准星
function zhunxing(x,y){
var ox=xo
var oy=yo
var oColor=color
color="#000000"
Line(x-5,y,x+6,y)
Line(x,y-6,x,y+5)
print('<span
>['+x+', '+y+']</span>')
color=oColor
雪成语xo=ox
yo=oy
}
//标注
function biaozhuStr(x,y,s){
return'<span
>'+s+'</span>' }
function biaozhu(x,y,s,t){
var ox=xo
var oy=yo
var oColor=color
point="p01.gif"
if(t==1){
print(biaozhuStr(x-5,y+6,"·"+s))
}
if(t==2){
print(biaozhuStr(xo+s(y*rad)-10,yo+x*Math.sin(y*rad),s))
}
color=oColor
xo=ox
yo=oy
}
</script>
</head>
<body>
<table border="0"width="100%">
<tr>
<td width="100%" class="t1">JavaScript绘图</td>
</tr>
文宣帝</table>
灵魂战记<script>
if(IE4){
//基本图形
color="maroon"
Cir(50,40,20)
Arc(100,40,20,60,120)
Pei(150,60,40,240,300)
Rect(200,20,40,40)
//折线图
color="#0066CC"
var jd=new Array(
232,234,265,232,255,277,298,199,283,288,221,195
)
MoveTo(30,jd[0]-40)
biaozhu(xo,yo,jd[0])
for(i=1;i<jd.length;i++){
LineTo(i*30+30,jd[i]-40)
biaozhu(xo,yo,jd[i],1)
}
color="#C0C0C0"
Line(30,140,i*30+30,140)
Line(30,140,30,260)
//饼图
color="#00FF00"
var gc=new Array(
150,120,200,180,180
)
var s=0
var m=0
var n=0
西葫芦种子for(i=0;i<gc.length;i++){
s+=gc[i]
if(gc[i]>m){
m=gc[i]
水方n=i
}
}
var k=s/360
var mm=0
var a=0
for(i=0;i<gc.length;i++){
und((gc[i]+mm)/k)

本文发布于:2023-05-15 01:06:57,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/634459.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:圆形   蛋糕   秘诀   重口
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图