Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created February 16, 2015 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicapow/68e21c4bf83ae87cca5a to your computer and use it in GitHub Desktop.
Save vicapow/68e21c4bf83ae87cca5a to your computer and use it in GitHub Desktop.
React + D3 boilerplate
var D3ReactTemplate = React.createClass({
sel: function() { return d3.select(this.getDOMNode()) },
getDefaultProps: function() {
return {
valueAccessor: function(d) { return d.value },
width: 400,
height: 400
}
},
getInitialState: function() {
var props = this.props
return {}
},
render: function() {
var props = this.props, data = props.data
var wrappedData = data.map(function(d) {
return { value: props.valueAccessor(d), d: d }
})
return React.DOM.svg(extend({style: style}, props), /* svgElements */)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment