Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds HTML file. Will convert over to JS at some point, but this works…
…. You just need to give it a dataset (an array of arrays).
- Loading branch information
1 parent
0e994d6
commit 54bf22b
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!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> |