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

Changing state to show custom tooltip, lib throws error: "Cannot set property 'options' of undefined "

Open namKolo opened this issue 9 years ago • 1 comments

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: image.
  • 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.

namKolo avatar Sep 20 '17 01:09 namKolo

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.

namKolo avatar Sep 20 '17 01:09 namKolo