-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'dragStarted' of undefined #10
Comments
+1 on this. I'm also using the plugin with react-chartjs-2, chart.js version 2.7.3 |
im also getting this problem. |
I checked out the code and found that the x-axis should be type linear or time, then plugin is working fine. |
Well that sucks. That means it isn't compatible with https://github.com/nagix/chartjs-plugin-streaming since it uses a "realtime" axis. |
Until this gets fixed, if you're also using the streaming plugin, you can get it to work with "realtime" scales by making a small change to the crosshair plugin's JS. Replacing all conditionals checking for "time" scales to use "realtime" as an alternative. ie.
|
I have a similar issue with using react-chartjs2.
with the data,
However it still gives the error dragStated undefined. |
@raymond1927 Any chance you have more than one chart on that page? If so, any charts which should not have the crosshair need to disable this plugin. Otherwise, this plugin will try to apply itself to every chart, even if it doesn't have the right scale type. |
@iamstickfigure Thanks for the help, how do I disable a plugin per chart. |
@raymond1927 https://www.chartjs.org/docs/latest/developers/plugins.html#disable-plugins
|
I tried the suggested options, which didn't work for me (using Chart.js 3.6.0). What I ultimately discovered is that for reasons unknown, the It also requires the X axis scale to be named 'x' and not 'xAxes'. I will submit a PR. |
Submitted PR #88. |
Is there any update on this? I noticed the PR is still unmerged. This issue happens for me whenever moving mouse over the chart area before the page is finished loading. |
nudge @AbelHeinsbroek |
Another temporary workaround that seems to work is to add optional chaining at trace.js#L277:
|
We just had to remove this plugin from a large production application given it intermittently caused blank screens for for our users. It would be an awesome one to fix, especially given there already appear to be proposed solutions. |
Uncaught TypeError: Cannot read property 'dragStarted' of undefined
at Object.beforeTooltipDraw (chartjs-plugin-crosshair.js:394)
at Object.notify (Chart.min.js:10)
at t._drawTooltip (Chart.min.js:10)
at t.draw (Chart.min.js:10)
at t.render (Chart.min.js:10)
at Object.callback (Chart.min.js:10)
at Object.advance (Chart.min.js:10)
at Object.startDigest (Chart.min.js:10)
at Chart.min.js:10
The text was updated successfully, but these errors were encountered: