Skip to content

Instantly share code, notes, and snippets.

@heybenchen
Created April 14, 2015 23:15
Show Gist options
  • Select an option

  • Save heybenchen/08329444afe9c0f33afc to your computer and use it in GitHub Desktop.

Select an option

Save heybenchen/08329444afe9c0f33afc to your computer and use it in GitHub Desktop.
React ChartJS Snippet
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