Skip to content

Instantly share code, notes, and snippets.

@samdroid-apps
Last active January 1, 2016 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samdroid-apps/8087172 to your computer and use it in GitHub Desktop.
Save samdroid-apps/8087172 to your computer and use it in GitHub Desktop.
Canvas Github-Code-Stats-Style Graph for Flask
<canvas id="myCanvas" height="20">
YOUR BROWSER IS TOO OLD
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var MAX = c.scrollWidth;
var total = {{ total }}
var entries = [{{ interface }},{{ code }}, {{ quality }}, {{ documentation }}];
var colors = ['#FFBB33', '#33B5E5', '99CC00', '#FF4444'];
var currentx = 0;
for (var i = 0; i < 4; i++) {
ctx.fillStyle=colors[i];
var x = currentx + ((entries[i]/total) * MAX);
ctx.fillRect(currentx,0,x,75);
currentx = x;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment