Created
April 14, 2015 23:15
-
-
Save heybenchen/08329444afe9c0f33afc to your computer and use it in GitHub Desktop.
React ChartJS Snippet
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
| render: function() { | |
| return ( | |
| <LineChart ref={this.bindClick} data={this.props.chartData} redraw options={chartOptions} width="600" height="200"/> | |
| ) | |
| } | |
| bindClick: function(chartComponent) { | |
| var self = this; | |
| if (chartComponent) { | |
| chartComponent.getCanvass().onclick = function(event) { | |
| var activePoints = chartComponent.getChart().getPointsAtEvent(event); | |
| if (activePoints && activePoints.length > 0) { | |
| var clickedLabel = activePoints[0].label; | |
| //do something with the clickedLabel | |
| } | |
| }; | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment