Created
October 21, 2015 17:41
-
-
Save jwo/8ade15a080c00fa278bc 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
//= 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