Skip to content

Instantly share code, notes, and snippets.

@jwo
Created October 21, 2015 17:41
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 jwo/8ade15a080c00fa278bc to your computer and use it in GitHub Desktop.
Save jwo/8ade15a080c00fa278bc to your computer and use it in GitHub Desktop.
//= require d3
var Chartie = React.createClass({
getInitialState(){
return {
datum: [
{
"values": [],
"key": "Average",
"color": '#ff7f0e'
}
]
}
},
componentWillUnmount(){
App.votesSubcription = {};
},
componentWillMount(){
var component = this;
App.votesSubcription = App.cable.subscriptions.create("VotesChannel", {
received(data) {
component.setState({datum: data});
}
});
},
render(){
return <div>
<NVD3Chart type='lineChart' datum={this.state.datum} ></NVD3Chart>
</div>
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment