Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (35 sloc) 1.11 KB
<!DOCTYPE html>
<html>
<head>
<title>Slopegraph.js</title>
<style type="text/css">
</style>
<script type="text/javascript">
var dataset=[[10, 100], [430, 441], [103, 89], [228, 62], [393, 258], [250, 167], [290, 322], [480, 17], [94, 27], [116, 163]]
var widthOfCanvas = '500';
var heightOfCanvas = dataset.join().split(',').sort(function(a,b){return b - a})[0];
window.onload = function() {
var drawingCanvas = document.getElementById('slopegraph');
drawingCanvas.setAttribute('width', widthOfCanvas);
drawingCanvas.setAttribute('height', heightOfCanvas);
if(drawingCanvas && drawingCanvas.getContext) {
var context = drawingCanvas.getContext('2d');
context.strokeStyle = "#ccc";
function chart(leftValue, rightValue){
context.moveTo(0,leftValue);
context.lineTo(widthOfCanvas, rightValue);
context.stroke();
};
for each (var value in dataset) {
chart(value[0], value[1]);
};
}
}
</script>
</head>
<body>
<canvas id="slopegraph">
<p>Your browser doesn't support canvas. Firefox and Chrome do, though.</p>
</canvas>
</body>
</html>