简体   繁体   English

D3,有什么方法可以逐点过渡到现有图形吗?

[英]D3, is there any way to transition through an existing graph point by point?

I was trying to find an example for something that I need to do, and unfortunately I have not found one. 我试图为需要做的事情找到一个例子,但是不幸的是我没有找到一个例子。 I have a scatter plot that I created, and the plot is just fine. 我创建了一个散点图,该图很好。 However, I am subscribing to a message, and each time I get that message, I need to find the point on the graph relating to the message, and make it larger. 但是,我正在订阅一条消息,每次收到该消息时,都需要在图形上找到与该消息有关的点,并将其放大。 When I transition to the next point, that point goes back to original size and I resize the new point. 当我过渡到下一个点时,该点将恢复为原始大小,并调整新点的大小。

Basically, it's a time series plot that every 5 seconds when I get the message, I advance one point (for now). 基本上,这是一个时间序列图,每当我收到消息时,每5秒钟就会前进一个点(目前)。 The thing is, the selectAll is an array of arrays. 问题是,selectAll是一个数组数组。 So, I guess where my issue is, I'm not sure where to use .attr("r", size). 因此,我想我的问题在哪里,我不确定在哪里使用.attr(“ r”,size)。

In my subscribe handler (callback), I check that the graph was created first, then I get all of the "points". 在我的订阅处理程序(回调)中,我检查是否首先创建了图形,然后获取了所有“点”。 From there, nothing was working. 从那里开始,没有任何工作。

Thanks for any help! 谢谢你的帮助!

Ideally, the data in your message is in the same format as the data used to generate the scatterplot. 理想情况下,消息中的数据与用于生成散点图的数据具有相同的格式。 Then you can rebind the data in the message to your points and use the selection.update function to resize just the updated datapoint. 然后,您可以将消息中的数据重新绑定到您的点,并使用selection.update函数仅调整更新后的数据点的大小。

Alternative you could use the selectAll function and filter only the elements you'd like to resize with the selection.filter function . 或者,您可以使用selectAll函数,并使用selection.filter函数仅过滤要调整大小的元素。

It would be helpful if you had a pastebin example of your script if you want more specific help. 如果需要脚本的pastebin示例,这将很有帮助。

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

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