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

tree 动态删除数据,第二次删除后无法渲染,报异常 #7315

Closed
sunxiongwei opened this issue Dec 19, 2017 · 5 comments
Closed
Assignees
Labels

Comments

@sunxiongwei
Copy link

One-line summary [问题简述]

动态删除数据,第二次删除后无法渲染,报异常

为了简单复现,可以每次删除根节点的第一个子节点:
root.children.splice(0, 1);
tab.treeChart.setOption($scope.getTreeDate(root), true);

第二次后开始报错

Version & Environment [版本及环境]

  • ECharts version3.8.5 [ECharts 版本]:
  • Browser version Chrome 版本 63.0.3239.84(正式版本) [浏览器类型和版本]:
  • OS Version MAC [操作系统类型和版本]:

Expected behaviour [期望结果]

解决

ECharts option [ECharts配置项]

option = {

                tooltip: {
                    trigger: 'item',
                    triggerOn: 'mousemove'
                },
                series: [
                    {
                        type: 'tree',
                        data: [data],
                        top: '1%',
                        left: '7%',
                        bottom: '1%',
                        right: '20%',
                        symbolSize: 17,
                        label: {
                            normal: {
                                position: 'left',
                                verticalAlign: 'middle',
                                align: 'right',
                                fontSize: 15
                            }
                        },
                        leaves: {
                            label: {
                                normal: {
                                    position: 'right',
                                    verticalAlign: 'middle',
                                    align: 'left'
                                }
                            }
                        },

                        expandAndCollapse: true,
                        animationDuration: 550,
                        animationDurationUpdate: 750
                    }
                ]
            
}

Other comments [其他信息]

@pissang pissang added the pending We are not sure about whether this is a bug/new feature. label Dec 20, 2017
@sunxiongwei
Copy link
Author

sunxiongwei commented Dec 21, 2017

添加 treeChart.clear(); 不再出现异常

    tab.treeChart.clear();
    tab.treeChart.setOption($scope.getTreeDate(tab.tree.root), true);

@pissang pissang added the bug label Dec 29, 2017
@pissang pissang removed the pending We are not sure about whether this is a bug/new feature. label Dec 29, 2017
@reuwi
Copy link

reuwi commented Dec 29, 2017

@sunxiongwei clear会清空实例中的数据,这样的话做不到局部更新数据,假如有很多子节点,默认一些子节点是被折叠的,手动展开这些子节点后向某个子节点下添加一个子节点,那么clear后重绘,这些子节点就又会被折叠了。理想的展示效果是局部更新节点,或者说是能够记住节点的折叠状态

@pissang
Copy link
Contributor

pissang commented Dec 29, 2017

@gaoshijun1993 嗯,这个是现在临时的 workaround,新版本会修复这个 bug

@raymondmars
Copy link

看了一下是因为node已经被移除,但是还在使用未移除时的索引造成的;找到了一个办法可以暂时Fix这个问题:
1,找到源代码下面的这个文件:echarts/src/chart/tree/TreeView.js
2, 找到 removeNode 方法,在无法找到node的时候,重新给node赋值
image

@deqingli
Copy link
Member

deqingli commented Apr 8, 2018

@sunxiongwei 你好,这个问题已经解决了,会随下个版本一起发布。欢迎验证,如果有问题可以 reopen 这个 issue,再次感谢给我们提建议!

@deqingli deqingli closed this as completed Apr 8, 2018
@deqingli deqingli self-assigned this Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants