react-chartjs
react-chartjs copied to clipboard
v2: support getElementAtEvent and getElementsAtEvent
I want to get elements by click events.
I can get elements:
const App = React.createClass({
handleClick(e) {
const chart = this.Bar.getChart()
chart.getElementAtEvent(e)
},
render() {
return (<Bar data={chartData} options={chartOption} onClick={this.handleClick} ref={(ref) => this.Bar = ref}/>)
}
})
But I want like getBarsAtEvent at v1:
const App = React.createClass({
handleClick(e) {
const chart = this.Bar.getElementAtEvent(e)
},
render() {
return (<Bar data={chartData} options={chartOption} onClick={this.handleClick} ref={(ref) => this.Bar = ref}/>)
}
})
Please refer the Prototype Methods section in the Chart.js document.
As far as I understand your point, bar.js need to be updated to :
var vars = require('./core');
module.exports = vars.createClass('Bar', ['getElementAtEvent']);
I think that should do the job :)