简体   繁体   English

如何删除以前绘制的InfoVis空间树

[英]How to Remove Previously Drawn InfoVis Space Tree

I am using InfoVis to generate a space tree visualization in one of my projects. 我正在使用InfoVis在我的一个项目中生成空间树可视化。 Since this is an interactive web site, the Space Tree needs to be regenerated each and every time the user has changed preferences. 由于这是一个交互式网站,因此每次用户更改偏好时都需要重新生成空间树。
This requires the Space Tree to be completely cleared and re-draw a new tree on the same space. 这需要完全清除空间树,然后在同一空间上重新绘制一棵新树。 In addition, the charting area can be re sized as the page size varies. 另外,可以随着页面大小的变化来调整图表区域的大小。 This requires re-draw of the Space Tree. 这需要重新绘制空间树。

I came across several issues while trying to clear the previously drawn Space Tree before drawing the new one. 在绘制新的空间树之前,我试图清除先前绘制的空间树时遇到了几个问题。 I am using the following code segment to clear the previous drawing, but it's failing miserably. 我正在使用以下代码段来清除先前的图形,但是它失败了。

st.clearNodesInPath();
st.labels.clearLabels(true);
st.canvas.clear();

If anyone can guide me how to resolve this that would be great as this is blocking my progress. 如果有人可以指导我如何解决此问题,那将非常好,因为这阻碍了我的进步。 Thanks in advance. 提前致谢。

在此处输入图片说明

This was resolved in the following manner. 这通过以下方式解决。

The InfoVis chart draws it's elements as HTML div elements inside the parent element. InfoVis图表将其元素绘制为父元素内的HTML div元素。 The problem was due to remainings of those generated div elements even after clearing up the data structures. 问题是由于即使清除了数据结构后,这些生成的div元素仍然保留。 Those were clearly shown in the previously attached images. 这些已在先前随附的图像中清晰显示。

This was resolved in the following manner. 这通过以下方式解决。

var list = document.getElementById("idOfParentElement");
list.removeChild(list.childNodes[0]);

The code fragment extracts the parent InfoVis element and clears up all of it's generated child elements. 该代码片段提取父InfoVis元素并清除其所有生成的子元素。 This will eventually clears the canvas object where the visualization will be drawn. 最终将清除将绘制可视化效果的画布对象。

This resolved my issue. 这解决了我的问题。 Hope this helps for anyone who is having the same issue. 希望这对遇到相同问题的任何人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM