Skip to content
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

TypeError: Cannot read property 'pos' of undefined #7872

Closed
Lir10 opened this issue Feb 15, 2018 · 18 comments
Closed

TypeError: Cannot read property 'pos' of undefined #7872

Lir10 opened this issue Feb 15, 2018 · 18 comments
Assignees

Comments

@Lir10
Copy link

Lir10 commented Feb 15, 2018

I'm using highcharts-ng with highcharts.js
Everytime i launch the graph i get this error:

angular.js:13920 TypeError: Cannot read property 'pos' of undefined
    at https://code.highcharts.com/stock/highstock.js:518:422
    at Array.forEach (<anonymous>)
    at a.each (https://code.highcharts.com/stock/highstock.js:27:466)
    at F.<anonymous> (https://code.highcharts.com/stock/highstock.js:518:396)
    at F.a.(anonymous function) [as getPlotLinePath] (https://code.highcharts.com/stock/highstock.js:19:437)
    at a.Tick.renderGridLine (https://code.highcharts.com/stock/highstock.js:113:264)
    at a.Tick.render (https://code.highcharts.com/stock/highstock.js:115:472)
    at F.renderTick (https://code.highcharts.com/stock/highstock.js:159:427)
    at https://code.highcharts.com/stock/highstock.js:160:448
    at Array.forEach (<anonymous>)

Any ideas?

@pawelfus
Copy link
Contributor

Hi @Lir10

Could you contact with our support? See: https://www.highcharts.com/support

We use github issues for bug reports. In your case I am not sure if this is a bug in Highstock, misconfigured chart or a bug in highcharts-ng module.

Any ideas?

Only one idea: error suggests xAxis/yAxis ticks issue, so I would try to remove options defined there and see if this resolves the issue. If yes, then please recreate issue in jsfiddle, without highcharts-ng to be sure it's a bug in Highstock lib.

@Lir10
Copy link
Author

Lir10 commented Feb 19, 2018

Hi @pawelfus ,

You were right - the problem was on the xAxis ticks

Closing the issue

@Lir10 Lir10 closed this as completed Feb 19, 2018
@bobheadxi
Copy link

@Lir10 May I ask what the problem was? I have the same issue and am trying to pinpoint the cause. Thanks!

@pawelfus
Copy link
Contributor

@bobheadxi

I would suggest to do this:

Any ideas?

Only one idea: error suggests xAxis/yAxis ticks issue, so I would try to remove options defined there and see if this resolves the issue. If yes, then please recreate issue in jsfiddle, without highcharts-ng to be sure it's a bug in Highstock lib.

@davletovalmir
Copy link

@Lir10, could you please describe where exactly was the problem, if you still remember? I'm facing the same issue, but I can't catch the circumstances, it just happens randomly, and unfortunately @pawelfus 's answer doesn't help pretty much.

@KacperMadej
Copy link

Hi @davletovalmir

If you will be able to provide a stable way to recreate the issue please share a link for the demo or files needed.

@davletovalmir
Copy link

davletovalmir commented Jan 20, 2019

@KacperMadej, I couldn't find the root cause yet, but here is what I've found out (I'm sorry in advance for a pieces of obfuscated code below):

  1. The error is thrown in step function, inside that block:
d.group.animate({
  scaleY: 1
}, G(z(d.options.animation), {
  step: function(a, b) {
    h[f] = v + b.pos * (c.pos - v); /// <-- b is undefined
    d.group.attr(h)
  }
}))
  1. step function is called here, as you can notice, with context, but without a and b args:
animate: function(e, q, b) {
  q = a.animObject(y(q, this.renderer.globalAnimation, !0));
  y(m.hidden, m.msHidden, m.webkitHidden, !1) && (q.duration = 0);
  0 !== q.duration ? (b && (q.complete = b),
    h(this, e, q)) : (this.attr(e, null, b),
  q.step && q.step.call(this)); /// <-- function called without arguments
  return this
}
  1. That animate function is part of SVGElement and was called inside render function.
  2. I've found the way to reproduce this, but it's weird. It happens on app's live reload, when chart is rendered for a first time, and mainly when focus is not on the browser.

I didn't have enough time to inspect that issue in depth. Hope what I've found will be helpful for you.

P.S. Also attaching piece of screenshot with console error. Not sure if it will help a lot, but who knows :)
image

@KacperMadej
Copy link

@davletovalmir
Thank you for the info - it's enough for me to recreate the problem.

Here's a workaround with code fix:
https://jsfiddle.net/BlackLabel/L6x08jeq/1/

You could apply the code fix from the demo into your code (like a module - after main Highcharts file). If you have time please check if this resolves the error in your app.

FYI: Not minified, human readable code for Highcharts related files is available by using files with .src.js - e.g. highcharts.src.js.

Details (a.k.a. the longer story):

when chart is rendered for a first time, and mainly when focus is not on the browser

That's something to check - this might be connected to a recent feature that prevents animation for unfocused browser cards / windows (because there's no need to animate when no one is watching).

I was able to get the correct corresponding code in not minified code. The key here is to use column series type.

Demo: https://jsfiddle.net/BlackLabel/L6x08jeq/
Steps:

  1. Open browser console
  2. Chart opens with no error, keep the console open
  3. Hit run button and hide the tab
  4. The error will show in console after chart will be rendered

Internal note:
H.pick((fx && fx.pos), 1) instead of fx.pos seems to be resolving the problem, but testing is required to confirm.

@davletovalmir
Copy link

@KacperMadej, thanks, that makes sense. Fix works :)
Could you please estimate when this fix will be released?

@KacperMadej
Copy link

@davletovalmir
The fix will be in PR this week and should be released with next Highcharts version.

In the meantime:

  • Now the solution is to add the wrapped code as seen in the demo.
  • After commit will be made Highcharts build withe the fix will be accessible through GitHub based link related to the branch with the fix.
  • After PR will be accepted Highcharts build with the fix will be accessible on master branch on GitHub based link - https://github.highcharts.com/highcharts.src.js

@TorsteinHonsi
Copy link
Collaborator

The issue was caused by the animate function not passing appropriate arguments to step when it bypassed animation, so I fixed it there instead.

@konstantintieber
Copy link

@KacperMadej how long until the next release? We just migrated from angular highcharts and would love to just install the version with the fix before merging our feature branch, instead of starting out with additional code to fix a bug, that won't be there anymore in a few days.

@KacperMadej
Copy link

Next version (7.0.3) is scheduled by the end of this week

@yhoiseth
Copy link

yhoiseth commented Feb 5, 2019

Is there an updated ETA?

@pawelfus
Copy link
Contributor

pawelfus commented Feb 5, 2019

Regression tests are in progress. Once all of the issues are resolved, new version will be released - I would expect new release soon, a few days max.

@TorsteinHonsi
Copy link
Collaborator

It's released now @yhoiseth

@yhoiseth
Copy link

yhoiseth commented Feb 6, 2019

Sweet! Thanks for letting me know 🙂

For some reason, GitHub didn't notify me, even though I'm "watching releases" for this repository 🤔

@pawelfus
Copy link
Contributor

pawelfus commented Feb 6, 2019

I don't know why you didn't get the notification, but still, you can sign up to our mailing list: https://www.highcharts.com/blog/download/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants