react-chartjs icon indicating copy to clipboard operation
react-chartjs copied to clipboard

v2: support getElementAtEvent and getElementsAtEvent

Open ledsun opened this issue 9 years ago • 1 comments

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.

ledsun avatar Jun 16 '16 09:06 ledsun

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 :)

kncs avatar Aug 11 '16 15:08 kncs