<canvas id="lineChart" width="400" height="300"></canvas>
var canvas = document.getElementById('lineChart');
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(50, 250);
ctx.lineTo(100, 200);
ctx.lineTo(150, 150);
ctx.lineTo(200, 100);
ctx.stroke();
<canvas id="barChart" width="400" height="300"></canvas>
var canvas = document.getElementById('barChart');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'blue';
ctx.fillRect(50, 200, 50, 100);
ctx.fillStyle = 'red';
ctx.fillRect(150, 150, 50, 150);
ctx.fillStyle = 'green';
ctx.fillRect(250, 100, 50, 200);
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com