Last active
January 1, 2016 03:39
-
-
Save samdroid-apps/8087172 to your computer and use it in GitHub Desktop.
Canvas Github-Code-Stats-Style Graph for Flask
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
<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