echarts icon indicating copy to clipboard operation
echarts copied to clipboard

fix(line): Ensure null check to avoid `Cannot set properties of null (setting 'hoverState')` error

Open svonderohe opened this issue 1 year ago • 3 comments

Brief Information

This pull request is in the type of:

  • [x] bug fixing
  • [ ] new feature
  • [ ] others

What does this PR do?

This PR fixes the following error:

Uncaught TypeError: Cannot set properties of null (setting 'hoverState')
    at setStatesFlag (states.js:117:1)
    at __webpack_modules__../node_modules/echarts/lib/chart/line/LineView.js.LineView._changePolyState (LineView.js:763:1)
    at Symbol.changePolyState [as onHoverStateChange] (LineView.js:667:1)
    at doChangeHoverState (states.js:72:1)
    at singleLeaveBlur (states.js:93:1)
    at states.js:311:1
    at __webpack_modules__../node_modules/zrender/lib/graphic/Group.js.Group.traverse (Group.js:131:1)
    at __webpack_modules__../node_modules/zrender/lib/graphic/Group.js.Group.traverse (Group.js:133:1)
    at states.js:310:1
    at Global.js:511:1

By removing a redundant call to setStatesFlag missing a null/undefined check

Fixed issues

I haven't created a separate issue, but I can if you would like

Details

Before: What was the problem?

There can be a race condition between the tooltip and instance.dispatchAction({type: 'downplay'}) that causes the chart to freeze with an exception

image

After: How does it behave after the fixing?

There is no longer an error

Document Info

One of the following should be checked.

  • [x] This PR doesn't relate to document changes
  • [ ] The document should be updated later
  • [ ] The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • [ ] Please squash the commits into a single one when merging.

Other information

svonderohe avatar Dec 05 '24 16:12 svonderohe

Thanks for your contribution! The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

echarts-bot[bot] avatar Dec 05 '24 16:12 echarts-bot[bot]

Thanks for your contribution. Can you add a test case for this fix?

plainheart avatar Dec 06 '24 02:12 plainheart

Thanks @plainheart, I have added a couple test cases

svonderohe avatar Dec 06 '24 15:12 svonderohe

It looks like this bug has been fixed through another change, closing PR...

svonderohe avatar Aug 05 '25 15:08 svonderohe