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

"Cannot read property '0' of undefined" error when stacked column chart is resized #4558

Closed
peter-scarab opened this issue Sep 10, 2015 · 9 comments
Assignees

Comments

@peter-scarab
Copy link

For a stacked column chart which is periodically updated, when the browser window is resized horizontally and the chart tries to change its width accordingly, a "Cannot read property '0' of undefined" error happens frequently.

In addition, when this happens, the points newly added to the second series start to appear on the column left to the last column, instead of the last column.

Demo: http://jsfiddle.net/peter_scarab/LLExL/5171/
Browser: Chrome 44
Tried with both the current master and bugfix branches.

@pawelfus
Copy link
Contributor

Workarounds:

Internal note:
Similar issue to #4557 - in short: we use series.index and point's index (i) from series.points array to get stack and corresponding points (this line) . In fact, series.points array may be unsynchronized - in #4557 for example we remove points which are inside the break so we needed to rebuild stacks.
I tried to use x-value instead of i, but this breaks multiple stacked points with the same x-value. We can not use point.index because dataGrouping doesn't provide such information. Any insights and/or suggestions?

@TorsteinHonsi
Copy link
Collaborator

What about using the x value plus som indicator in case the of multiple stacked points? So if the x value for that series has been taken before, we add 1,2,3,4 etc? It's just a thought, I don't know if it works well...

@pawelfus
Copy link
Contributor

Let me know what do you think. I will write a test for that case if this is fine.

@pawelfus
Copy link
Contributor

Solution above is more generic - we can revert #4557 commit, unless you think this is a good idea to rebuild stacks after modifying points array. We don't need to do that, but it will release a bit of memory (since some of stacks will disappear when are created inside the break). However, we would need to rebuild stacks so it would require extra CPU (a bit, but still!) ;)

@TorsteinHonsi
Copy link
Collaborator

Yes, it's probably better to revert the #4557 commit to save CPU.

Let me know what do you think. I will write a test for that case if this is fine.

It seems like a robust solution. Maybe there's room for micro optimization, like constructing the empty stackIndicator, and generating the key?

@pawelfus
Copy link
Contributor

Done in this commit and this one. I wasn't sure about generating the key so it's split in two commits, in case of reverting. Thanks!

@TorsteinHonsi
Copy link
Collaborator

Excellent, thanks! I pulled the fix and the optimizations and reverted the 4557 fix.

@pawelfus pawelfus self-assigned this Sep 28, 2015
@shashivardhan
Copy link

shashivardhan commented Mar 1, 2018

I still see a similar problem when using highstock with stacked bar chart and scroll bar enabled, which has 100 categories.
https://jsfiddle.net/shashi3337/5xn92uht/1/
When I am using the scroll, I don't see the stacked bar on the chart and when I scroll back to initial position I'm getting this error
"Cannot read property '0' of undefined" error when stacked column chart is resized"

@pawelfus
Copy link
Contributor

pawelfus commented Mar 2, 2018

Hi @shashivardhan - it's a bug in categorized axis, setting cropThreshold resolves the issue: https://jsfiddle.net/5xn92uht/5/ I see you reported this here: #7944

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

No branches or pull requests

4 participants