vis-timeline icon indicating copy to clipboard operation
vis-timeline copied to clipboard

'Cannot redraw item: no parent attached' if cluster exists when nested groups are expanded

Open async0x42 opened this issue 6 years ago • 6 comments

If clusters would be drawn when expanding a nested group, it throws the following error:

Error:

ClusterItem.js:462 Uncaught Error: Cannot redraw item: no parent attached
    at e.value (ClusterItem.js:462)
    at Group.js:1110
    at Object.forEach (esm.js:5481)
    at t.value (Group.js:1109)
    at t.value (Group.js:403)
    at Array.<anonymous> (Group.js:517)
    at ItemSet.js:840
    at Object.forEach (esm.js:5481)
    at i (ItemSet.js:839)
    at ItemSet.js:838

The error only occurs if the clusters would exist on expanding the group. In other projects, if you're zoomed in and no clusters would be made, expand the group, then zoom out, no errors happen.

Example (based off official docs for nested groups): (open dev tools and attempt to expand a group): https://jsbin.com/qucozujemu/2

async0x42 avatar Nov 05 '19 20:11 async0x42

I subscribed to this thread, just wondering if there is any update on this issue. I too am experiencing this.

Hookwitz avatar Mar 20 '20 21:03 Hookwitz

+1

jvictorsoto avatar May 19 '20 21:05 jvictorsoto

Still an issue :"(

SatorCube avatar Jul 26 '21 17:07 SatorCube

Hey guys, I encountered this problem as well. Here is my workaround which seems to be working for my problem. Maybe you can use it as well. I was programmatically collapsing and uncollapsing the groups: (from the click handler I was able to get which group was clicked and thus the subgroupId) const subgroup = timelineGroups.get(subgroupId); timelineGroups.update({ id: subgroupId, visible: !subgroup.visible }); This resulted in the same error as when I made my groups visible again, the clustered items triggered this error. So I disabled and then reenabled the clustering after updating the groups with the timeline.setOptions function

So the final code should look like something like this:

I use the react version of the timeline, so that's why there is a timelineRef in the code. Don't forget the reenable your original clustering rules, if there was one.

timelineRef.current.timeline.setOptions({ cluster: {
    titleTemplate: undefined,
    clusterCriteria: () => false,
} });

const subgroup = timelineGroups.get(subgroupId);
timelineGroups.update({ id: subgroupId, visible: !subgroup.visible });

timelineRef.current.timeline.setOptions({ cluster: {
  titleTemplate: undefined,
  clusterCriteria: () => true,
} });

Bengya avatar Feb 28 '22 19:02 Bengya

I had this issue recently. I fixed it by doing the following:

this.timeline.on('click', (properties) => {
    switch (properties.what) {
        case 'group-label': {
            let group = this.groups.get(properties.group)
            if (group && group.showNested == false) {
                this.timeline.itemSet.clusterGenerator.updateData()
            }

            break
        }
    }
})

The problem I had was that upon closing a group (with nested subgroups), the timeline would not render correctly.

braedinski avatar Jul 29 '22 03:07 braedinski