Last active
August 29, 2015 14:04
-
-
Save martinaglv/3511674068491ef0161f to your computer and use it in GitHub Desktop.
Sparklines
This file contains hidden or 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
#!/usr/bin/env node | |
var ticks = '▁▂▃▄▅▆▇'.split(''), | |
values = process.argv.slice(2); | |
var min = Math.min.apply(0, values), | |
range = Math.max.apply(0, values) - min, | |
scale = ticks.length - 1; | |
console.log( values.map(function(x){ | |
return ticks[ Math.round(((x - min) / range) * scale) ]; | |
}).join('') ); |
This file contains hidden or 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
./spark.js 3 20 1 8 12 9 40 | |
▁▄▁▂▃▂▇ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment