react-chartjs-2
react-chartjs-2 copied to clipboard
Changing state to show custom tooltip, lib throws error: "Cannot set property 'options' of undefined "
Hello all. First of all, I really love our wrapper lib for ChartJS. I played with this lib yesterday and I figured out it was really useful.
- When I tried to start writing a custom tooltips for a line chart by using state (I followed the suggestion here #151) , I was stuck by this error:
. - Even the code still runs, but it always throws this exception. The tooltip appeared but once I change state, it throws that error.
- As I search in our github, I found #90 involve with my issue. It looks like that I need
redraw. I tried but the performance not good. Please help me. Thanks all.
P/S Sorry for my bad english. And thanks for your reading and concern.
Ahhh. I figure out why it happens to me.
const options = {
tooltips: {
enabled: false,
mode: 'point',
intersect: true,
custom: tooltipModel => {
...something here ...
}
}
}
I made the custom function as a method of component. Then everything worked fine.
I think It happens because whenever re-rendering, it creates new custom function - so it threw errors.