Highcharts: TypeError: Cannot read property 'pos' of undefined

Created on 15 Feb 2018  ·  18Comments  ·  Source: highcharts/highcharts

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?

Bug

Most helpful comment

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

All 18 comments

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.

Hi @pawelfus ,

You were right - the problem was on the xAxis ticks

Closing the issue

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

@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.

@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.

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.

@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

@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.

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

@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

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

@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.

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

Is there an updated ETA?

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.

It's released now @yhoiseth

Sweet! Thanks for letting me know 🙂

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

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/

Was this page helpful?
0 / 5 - 0 ratings