You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe it's a mistake to only delete the metaset if it has a valid controller; see f191f2f for where this behavior was introduced.
This is a minimal fix for chartjs#9653; as discussed there, it may also be worth updating `updateHoverStyle`.
As of chartjs#7030, `this._metasets` should always be defined, so checking whether it's undefined is no longer necessary.
* Fix cleaning up metasets
I believe it's a mistake to only delete the metaset if it has a valid controller; see f191f2f for where this behavior was introduced.
This is a minimal fix for #9653; as discussed there, it may also be worth updating `updateHoverStyle`.
As of #7030, `this._metasets` should always be defined, so checking whether it's undefined is no longer necessary.
* Add a test covering metaset behavior
* Add a regression test for #9653; fix `toHaveSize` usage
* Fix test failure
Expected Behavior
Assigning to
chart.data.datasets
and then usingchart.update
to refresh the chart should work.Current Behavior
Under (roughly) the following sequence of events, an error is triggered:
The specific error is "Cannot read properties of null (reading 'buildOrUpdateElements')" on this line.
From exploring in the debugger, the sequence of events appears to be
chart.update()
goes to replay the last event.updateHoverStyle
, which tries to get the metaset for the dataset index for the hovered point.getDatasetMeta
creates an empty metaset that's never properly updated.Possible Solution
Should
updateHoverStyle
check whether the dataset index is valid before trying to retrieve the metaset?Alternatively, or as well, I believe that
_destroyDatasetMeta
has a bug; the current code should probably be(I made this change in my local copy, and it appears to fix the bug.)
Or, because deleting a non-existent element should be harmless:
I wasn't sure if changing updateHoverStyle fits with Chart.js's design; I can submit a PR for whatever fix seems best.
Steps to Reproduce
https://codesandbox.io/s/optimistic-perlman-705ce?file=/src/index.js
Mouse over the chart while data is visible, then wait for it to disappear and reappear.
Environment
The text was updated successfully, but these errors were encountered: