-
-
Save karlbright/b1034b467cfe2c8b454e to your computer and use it in GitHub Desktop.
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
const d3 = { svg: { axis: d3axis } }; | |
function noop(x) { console.log('called with', x); return d3axis(); } | |
function d3axis() { return { scale: noop, range: noop } } | |
class Axis { | |
constructor(obj) { | |
this.props = obj || {}; | |
} | |
render() { | |
let a = new d3.svg.axis(); | |
for(let key in this.props) { | |
if(this.props.hasOwnProperty(key) && typeof a[key] === 'function') { | |
a = a[key].call(a, this.props[key]); | |
} | |
} | |
return a; | |
} | |
} | |
var myAxis = new Axis({ | |
scale: 1, | |
range: 2, | |
color: '#000' | |
}); | |
myAxis.render(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment