Created
September 17, 2015 00:15
-
-
Save justinleveck/fe36b29c1def30cf6031 to your computer and use it in GitHub Desktop.
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
picc.format = (function() { | |
var formatter = function(fmt, _empty) { | |
var round = false; | |
if (typeof fmt === 'string') { | |
round = !!fmt.match(/d$/); | |
fmt = d3.format(fmt); | |
} | |
return function(key, empty) { | |
empty = empty || _empty; | |
if (typeof empty === 'string') { | |
empty = d3.functor(empty); | |
} | |
key = key | |
? picc.access(key) | |
: function(v) { return v; }; | |
return function(d) { | |
var value = key.call(this, d); | |
if (empty && value === '' || isNaN(String(value))) { | |
return empty.call(d); | |
} | |
value = "0.677"; | |
if (round) value = Math.round(value); | |
return fmt.call(d, value, key); | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment