简体   繁体   English

d3散点图圆圈在更新时呈现不同

[英]d3 scatterplot circles rendering differently on update

Here I have the code for my scatterplot. 这里我有我的散点图的代码。 https://github.com/laran/eisenhower/blob/master/components/plot/scatterplot.js https://github.com/laran/eisenhower/blob/master/components/plot/scatterplot.js

This is what the plot looks like when it is initially rendered which is done by calling .setup() and then .update(). 这是最初渲染时的情节,通过调用.setup()然后调用.update()来完成。 在此输入图像描述

This is what the plot looks like after a point is added (data points changed and plot updated) . 这是在添加点(数据点已更改并更新绘图)后的情节图 在此输入图像描述

You'll notice that in addition to there being one more point on the second plot, while the new circle has a black outline, all of the circles that were already there have had their black outline removed. 您会注意到,除了第二个绘图上还有一个点,而新圆圈有一个黑色轮廓,所有已经存在的圆圈都删除了黑色轮廓。

My question is why do the black circle outlines disappear after update ? 我的问题是为什么黑色圆圈轮廓在更新后会消失

And, for bonus points : After updating one of the data points and calling Application.Plotter.update(), the dots often don't update. 并且,对于奖励积分 :在更新其中一个数据点并调用Application.Plotter.update()之后,这些点通常不会更新。 Why don't the circles update after changing the data values and calling Application.Plotter.update()? 更改数据值并调用Application.Plotter.update()后,为什么圆圈不会更新?

I have a feeling that there's something of in how I'm calling enter() or exit() on the plot. 我有一种感觉,就是我在剧情中调用enter()或exit()的方式。 But I'm not familiar enough with d3 to really understand what I've done wrong. 但我对d3不够熟悉,才能真正理解我做错了什么。

Thanks! 谢谢!

I fixed the issue by calling .exit().remove() before calling .enter().append(). 我通过在调用.enter()。append()之前调用.exit()。remove()来解决这个问题。

https://github.com/laran/eisenhower/commit/4a23906f17723449a5f1d4901279d32cbcf26870 https://github.com/laran/eisenhower/commit/4a23906f17723449a5f1d4901279d32cbcf26870

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

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