Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sparklines in CoffeeScript
#!/usr/bin/env coffee
ticks = ['','','','','','','','']
exports.clark = (data) ->
m = Math.min data...
n = (Math.max(data...)-m)/(ticks.length - 1)
(ticks[(t-m)/n >> 0] for t in data).join('')
if require.main == module
data = process.argv
.map((a) -> parseInt(a, 10))
.filter((v) -> v==v)
process.stdout.write("#{exports.clark(data)}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.