首页 > 其他 > 详细

绘制饼状图效果

时间:2018-08-20 15:01:12      阅读:217      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			#canvas{
				background: #988E75;
				margin: 0 auto;
				display: block;
				position: relative;
			}
			
		</style>
	</head>
	<body>
		
		<canvas id="canvas" width="800" height="500"></canvas>
	</body>
	<script>
		var canvas=document.getElementById(‘canvas‘);
		var cv=canvas.getContext(‘2d‘);
		cv.lineWidth=5;
		cv.strokeStyle=‘yellow‘;
		
		cv.beginPath();
		cv.moveTo(300,200);
		cv.arc(300,200,150,0,60*Math.PI/180);
		cv.closePath();
		cv.fillStyle=‘pink‘;
		cv.fill();
		
		cv.beginPath();
		cv.moveTo(300,200);
		cv.arc(300,200,150,60*Math.PI/180,110*Math.PI/180);
		cv.closePath();
		cv.fillStyle=‘green‘;
		cv.fill();
		
		cv.beginPath();
		cv.moveTo(300,200);
		cv.arc(300,200,150,110*Math.PI/180,220*Math.PI/180);
		cv.closePath();
		cv.fillStyle=‘yellow‘;
		cv.fill();
		
		
		cv.beginPath();
		cv.moveTo(300,200);
		cv.arc(300,200,150,220*Math.PI/180,300*Math.PI/180);
		cv.closePath();
		cv.fillStyle=‘blue‘;
		cv.fill();
		
		cv.beginPath();
		cv.moveTo(300,200);
		cv.arc(300,200,150,300*Math.PI/180,360*Math.PI/180);
		cv.closePath();
		cv.fillStyle=‘orange‘;
		cv.fill();
	</script>
</html>

 技术分享图片

 

绘制饼状图效果

原文:https://www.cnblogs.com/gxywb/p/9505533.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!