Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Timeline - Uncaught TypeError: Cannot read property 'height' of undefined #2594

Closed
ghost opened this issue Jan 17, 2017 · 13 comments
Closed
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Jan 17, 2017

Hi all,

First I want to say how much I love vis.js library, it saved me months of time to developp a timeline like yours.

I got an error Error on visjs 4.16.1 and 4.18.0 when i try to move a subgrouped item in another group :

vis.js:21715 Uncaught TypeError: Cannot read property 'height' of undefined
    at http://localhost:63342/rms/bower_components/vis/dist/vis.js:21715:94
    at Object.exports.forEach (http://localhost:63342/rms/bower_components/vis/dist/vis.js:718:9)
    at Group._calculateSubGroupHeights (http://localhost:63342/rms/bower_components/vis/dist/vis.js:21713:12)
    at Group.redraw (http://localhost:63342/rms/bower_components/vis/dist/vis.js:21635:10)
    at http://localhost:63342/rms/bower_components/vis/dist/vis.js:19374:32
    at Object.exports.forEach (http://localhost:63342/rms/bower_components/vis/dist/vis.js:724:11)
    at ItemSet.redraw (http://localhost:63342/rms/bower_components/vis/dist/vis.js:19372:10)
    at http://localhost:63342/rms/bower_components/vis/dist/vis.js:18495:27
    at Array.forEach (native)
    at Timeline.Core._redraw (http://localhost:63342/rms/bower_components/vis/dist/vis.js:18494:21)

If I catch this error I got another one on line 22179 and when I catch the second (in a console.warn) all looks good.

How can i fix it ?

@ghost ghost changed the title vis.js:21715 Uncaught TypeError: Cannot read property 'height' of undefined Timeline - Uncaught TypeError: Cannot read property 'height' of undefined Jan 17, 2017
@blin4444
Copy link

blin4444 commented Jan 17, 2017

I'm receiving possibly related errors after upgrading from 4.17.0 to 4.18.0. Needed to downgrade back to 4.17.0.

[Error] Error: undefined is not an object (evaluating 'orderedItems[Math.max(0, middle - 1)]')
      binarySearchValue@[domain]/js/bundle.js:77492:31
      _getRelevantData@[domain]/js/bundle.js:106123:57
      _updateGraph@[domain]/js/bundle.js:105944:30
      redraw@[domain]/js/bundle.js:105879:34
      [domain]/js/bundle.js:105432:21
      emit@[domain]/js/bundle.js:87930:27
      [native code]
      setRange@[domain]/js/bundle.js:95487:31
      setOptions@[domain]/js/bundle.js:95344:22
      forEach@[native code]
      setOptions@[domain]/js/bundle.js:97046:28
      setOptions@[domain]/js/bundle.js:105112:35
      [domain]/js/bundle.js:135085:33
      $watchCollectionAction@[domain]/js/bundle.js:27939:21
      $digest@[domain]/js/bundle.js:28076:25
      $apply@[domain]/js/bundle.js:28342:31
      [domain]/js/bundle.js:135419:28
      $emit@[domain]/js/bundle.js:28487:38
      [domain]/js/bundle.js:135369:27
      [domain]/js/bundle.js:62001:24
      applyAsyncOrDigest@[domain]/js/bundle.js:10123:25
      _onMessageHandler@[domain]/js/bundle.js:10112:29
      (anonymous function) (bundle.js:21099)
      $digest (bundle.js:28094)
      $apply (bundle.js:28342)
      (anonymous function) (bundle.js:135419)
      $emit (bundle.js:28487)
      (anonymous function) (bundle.js:135369)
      (anonymous function) (bundle.js:62001)
      applyAsyncOrDigest (bundle.js:10123)
      _onMessageHandler (bundle.js:10112)

@mojoaxel mojoaxel modified the milestone: Patch release v4.18.1 Jan 18, 2017
@yotamberk yotamberk self-assigned this Jan 22, 2017
@yotamberk
Copy link
Contributor

yotamberk commented Jan 27, 2017

@jtissier @blin4444 I am not able to reproduce this bug...
Can you please supply a jsbin with an example with this error popping up?

@mojoaxel
Copy link
Member

Looking at the subgroups example I can not reproduce this, by tracking any item to another group.
@@jtissier @blin4444 Please provide a way for us to reproduce this. Thx!

@mojoaxel mojoaxel modified the milestones: Patch release v4.18.1, Patch Release v4.18.2 Jan 29, 2017
@ghost
Copy link
Author

ghost commented Jan 30, 2017

I will try to provide you a jsbin soon

@blin4444
Copy link

blin4444 commented Jan 30, 2017

It will be a bit difficult for me to do because I am using Vis commercially. It may take a while.

@mojoaxel mojoaxel modified the milestones: Patch Release v4.18.2, Minor Release v4.19 Feb 3, 2017
@yotamberk
Copy link
Contributor

@jtissier @blin4444 any progress? I want to help but I can't reproduce it. I need your examples

@blin4444
Copy link

@blin4444 did you receive my emails? Thanks.

@ghost
Copy link
Author

ghost commented Feb 14, 2017

Sorry I can not share the whole code and it is very difficult to reproduce this bug for now because I have to finish the project soon.

For now I just add some try/catch to prevent the error when I drag an item between groups and the script failed to calculate height of subgroup (probably because the subgroup has been removed dynamically in my code)

I updated to 4.18.1 and the same error occurs in line 25320 when I tried to show/hide groups depending on the showed items ( based on this code: http://jsfiddle.net/zwwspLnz/ ).

Like the old version, the error appears when the script tries to calculate the subgroup. The line in vis.js is :
me.subgroups[item.data.subgroup].height = Math.max(me.subgroups[item.data.subgroup].height, item.height + margin.item.vertical);

But this time it occurs during the dynamic load. I think I will try another way to hide groups.

@santacruzd7
Copy link

Hello everyone,

I believe I've encountered the same problem as you, but in a different use case. I'm currently using the VIS timeline to generate a timeline with groups and subgroups of events. Basically, the thing is that from time to time I need to remove events from the subgroups and rearrange the subgroups consistently

For instance, if I have the following setting:

  • Event A (subgroup 0)
  • Event B (subgroup 1)
  • Event C (subgroup 2)
  • Event D (subgroup 3)

And I remove the Event B, the following result is expected:

  • Event A (subgroup 0)
  • Event C (subgroup 1)
  • Event D (subgroup 2)

as opposed to:

  • Event A (subgroup 0)
  • Event C (subgroup 2)
  • Event D (subgroup 3)

I'm handling myself the update of the subgroups, but it seems that VIS isn't handling well the update of events, removing and re-adding subgroups and failing sometimes in re-adding deleted groups.

The following example demonstrates the problem. You will be able to see the error logs in the console:
https://plnkr.co/edit/LkRb8w6ndw5ijnPUnupb?p=preview

In addition to failing on the re-calculation of the height (it seems to have removed a group and not re-added it), for some reason, after the second click, the events in the second row (subgroup 1) get moved to the last row (subgroup 8).

Thank you very much for your help!

BTMorton pushed a commit to BTMorton/vis that referenced this issue Mar 3, 2017
Add method to change the subgroup an item is in.
No longer decrement subgroup ID when removing a subgroup.
Fixes almende#2594
@Tooa Tooa added Confirmed Bug and removed Problem labels Mar 5, 2017
@Tooa
Copy link
Member

Tooa commented Mar 5, 2017

@jtissier @santacruzd7 @blin4444 can you please test the pull request #2821 and check if this solves your problems?

@santacruzd7
Copy link

Dear @Tooa,

I've tested the pull request and it solved my issue. Thank you very much :)

@blin4444
Copy link

@Tooa, I've tried the pull request and now I get the following error from vis.js line 29767:
undefined is not an object (evaluating 'fieldId')

yotamberk pushed a commit that referenced this issue Mar 18, 2017
* Add methods to remove and add items to a subgroup.
Add method to change the subgroup an item is in.
No longer decrement subgroup ID when removing a subgroup.
Fixes #2594

* Moved the orderSubgroups call outside of the add/remove methods.
Added the ability to call the add/remove methods without a subgroupId parameter (takes from item data instead).
@yotamberk
Copy link
Contributor

@blin4444 please open a new issue with a jsbin of your example

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

No branches or pull requests

5 participants