Skip to content

Instantly share code, notes, and snippets.

@karlbright
Created June 16, 2015 04:58
Show Gist options
  • Save karlbright/b1034b467cfe2c8b454e to your computer and use it in GitHub Desktop.
Save karlbright/b1034b467cfe2c8b454e to your computer and use it in GitHub Desktop.
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