react-chartjs
react-chartjs copied to clipboard
Get points on event returns empty array.
handleOnClick(event) { console.log(this.refs.lineChart.getPointsAtEvent(event)); }
As title states, this console log always returns empty array even though graph is showing a lot of data.
are you extending the class ? my this.refs
only has { canvass: ... }
I am not sure how you are able to do this otherwise.
It would help to debug it if you post more code.
You can make use of extensions to get a reference to this canvas.
const Chart = require('react-chartjs');
class YourChart extends Chart.Line {
constructor(props) {
super(props);
}
componentDidMount() {
this.initializeChart(this.props);
const chart = this;
this.refs.canvass.onclick = function(e) {
console.log(chart.getPointsAtEvent(e));
}
}
};