欢迎来到天天文库
浏览记录
ID:57160461
大小:40.50 KB
页数:4页
时间:2020-08-04
《直方图饼图教学文稿.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、直方图饼图精品文档开始输入数据数量number,数据array[],以及相应的数据名称Array[]i=0;总数SUM=0;i2、extendsApplet{publicvoidpaint(Graphicsg){finalintarray[]={50,130,170,300,250,100};finalStringArray[]={"婴儿","儿童","少年","青年","中年","老年"};finalintnumber=6;intStartAngle=0,ArcAngle=0;finalintHIGH=450;inthigh=0,COLOR=0,wi=60;doubleroto=0;StringRoto="0";intSUM=0;for(inti=0;i3、UM+array[i];}g.drawLine(50,50,50,HIGH);g.drawLine(50,HIGH,HIGH,HIGH);g.setColor(Color.DARK_GRAY);//设置字体的颜色Fontf=newFont("黑体",Font.TRUETYPE_FONT,20);g.setFont(f);g.drawString("图例:",50,HIGH+50);g.drawOval(600,200,HIGH,HIGH);//画圆for(inti=0;i4、e;high=array[i]*1000/SUM;roto=array[i]*100/SUM;Roto=String.valueOf(roto);DoubleD1=newDouble(high*3.6/10);ArcAngle=D1.intValue();COLOR=i*30;//颜色Colorc=newColor(10,225-COLOR,COLOR);g.setColor(c);if(i>0)wi=wi+35;g.fillRect(wi,(HIGH-high),25,high);//画直方图if(i==number-1)收集于网络,如有侵权请联系管理员删除精品5、文档g.fillArc(600,200,HIGH,HIGH,StartAngle,360-StartAngle);elseg.fillArc(600,200,HIGH,HIGH,StartAngle,ArcAngle);//饼图g.fillRect(50,HIGH+55+25*i,20,20);//以下为图例g.drawString(Array[i]+""+Roto+"%",100,HIGH+75+25*i);}//theendoffor(1)//}//theendofif}//theendofpaint}//theendofTest2、运行结果输入的数据婴儿506、,儿童130,少年170,青年300,中年250,老年100收集于网络,如有侵权请联系管理员删除
2、extendsApplet{publicvoidpaint(Graphicsg){finalintarray[]={50,130,170,300,250,100};finalStringArray[]={"婴儿","儿童","少年","青年","中年","老年"};finalintnumber=6;intStartAngle=0,ArcAngle=0;finalintHIGH=450;inthigh=0,COLOR=0,wi=60;doubleroto=0;StringRoto="0";intSUM=0;for(inti=0;i3、UM+array[i];}g.drawLine(50,50,50,HIGH);g.drawLine(50,HIGH,HIGH,HIGH);g.setColor(Color.DARK_GRAY);//设置字体的颜色Fontf=newFont("黑体",Font.TRUETYPE_FONT,20);g.setFont(f);g.drawString("图例:",50,HIGH+50);g.drawOval(600,200,HIGH,HIGH);//画圆for(inti=0;i4、e;high=array[i]*1000/SUM;roto=array[i]*100/SUM;Roto=String.valueOf(roto);DoubleD1=newDouble(high*3.6/10);ArcAngle=D1.intValue();COLOR=i*30;//颜色Colorc=newColor(10,225-COLOR,COLOR);g.setColor(c);if(i>0)wi=wi+35;g.fillRect(wi,(HIGH-high),25,high);//画直方图if(i==number-1)收集于网络,如有侵权请联系管理员删除精品5、文档g.fillArc(600,200,HIGH,HIGH,StartAngle,360-StartAngle);elseg.fillArc(600,200,HIGH,HIGH,StartAngle,ArcAngle);//饼图g.fillRect(50,HIGH+55+25*i,20,20);//以下为图例g.drawString(Array[i]+""+Roto+"%",100,HIGH+75+25*i);}//theendoffor(1)//}//theendofif}//theendofpaint}//theendofTest2、运行结果输入的数据婴儿506、,儿童130,少年170,青年300,中年250,老年100收集于网络,如有侵权请联系管理员删除
3、UM+array[i];}g.drawLine(50,50,50,HIGH);g.drawLine(50,HIGH,HIGH,HIGH);g.setColor(Color.DARK_GRAY);//设置字体的颜色Fontf=newFont("黑体",Font.TRUETYPE_FONT,20);g.setFont(f);g.drawString("图例:",50,HIGH+50);g.drawOval(600,200,HIGH,HIGH);//画圆for(inti=0;i4、e;high=array[i]*1000/SUM;roto=array[i]*100/SUM;Roto=String.valueOf(roto);DoubleD1=newDouble(high*3.6/10);ArcAngle=D1.intValue();COLOR=i*30;//颜色Colorc=newColor(10,225-COLOR,COLOR);g.setColor(c);if(i>0)wi=wi+35;g.fillRect(wi,(HIGH-high),25,high);//画直方图if(i==number-1)收集于网络,如有侵权请联系管理员删除精品5、文档g.fillArc(600,200,HIGH,HIGH,StartAngle,360-StartAngle);elseg.fillArc(600,200,HIGH,HIGH,StartAngle,ArcAngle);//饼图g.fillRect(50,HIGH+55+25*i,20,20);//以下为图例g.drawString(Array[i]+""+Roto+"%",100,HIGH+75+25*i);}//theendoffor(1)//}//theendofif}//theendofpaint}//theendofTest2、运行结果输入的数据婴儿506、,儿童130,少年170,青年300,中年250,老年100收集于网络,如有侵权请联系管理员删除
4、e;high=array[i]*1000/SUM;roto=array[i]*100/SUM;Roto=String.valueOf(roto);DoubleD1=newDouble(high*3.6/10);ArcAngle=D1.intValue();COLOR=i*30;//颜色Colorc=newColor(10,225-COLOR,COLOR);g.setColor(c);if(i>0)wi=wi+35;g.fillRect(wi,(HIGH-high),25,high);//画直方图if(i==number-1)收集于网络,如有侵权请联系管理员删除精品
5、文档g.fillArc(600,200,HIGH,HIGH,StartAngle,360-StartAngle);elseg.fillArc(600,200,HIGH,HIGH,StartAngle,ArcAngle);//饼图g.fillRect(50,HIGH+55+25*i,20,20);//以下为图例g.drawString(Array[i]+""+Roto+"%",100,HIGH+75+25*i);}//theendoffor(1)//}//theendofif}//theendofpaint}//theendofTest2、运行结果输入的数据婴儿50
6、,儿童130,少年170,青年300,中年250,老年100收集于网络,如有侵权请联系管理员删除
此文档下载收益归作者所有