Alguém poderia me ajudar com esse código?
Não há mensagem de erro, mas só aparece período (anos) da série.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Gráfico de Barras</title>
<canvas width="600" height="400"></canvas>
</head>
<body>
<script type="text/javascript">
function drawRectangle(x, y, width, height, color) {
var screen = document.querySelector ("canvas");
var brush = screen.getContext ("2d");
brush.fillStyle = color;
brush.fillRect = (x, y, width, height);
brush.strokeStyle = "black";
brush.strokeRect = (x, y, width, height);
}
function write(text, x, y){
var screen = document.querySelector ("canvas");
var brush = screen.getContext ("2d");
brush.font = "15xp Georgia";
brush.fillStyle = "black";
brush.fillText (text, x, y);
}
function drawBar(x, y, serie, colors, text){
write(text, x, y-10);
sumHeight = 0;
for (var position = 0; position < serie.length; position++) {
var height = serie[height];
drawRectangle(x, y + sumHeight, 50, height, colors[position]);
var sumHeight = sumHeight + height;
}
}
var colors = ["blue", "green", "yellow", "red"];
var serie2015 = [50, 25, 20, 5];
var serie2016 = [65, 20, 13, 2];
drawBar (50, 50, serie2015, colors, "2015");
drawBar (150, 50, serie2016, colors, "2016");
</script>
</body>
</html>