无法读取未定义的属性“力"(简单D3网络图) [英] Cannot read property 'force' of undefined (Simple D3 Network graph)

查看:197
本文介绍了无法读取未定义的属性“力"(简单D3网络图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉D3和Javascript,但通常运气不错,只需复制基本的D3脚本并将数据转换为正确的格式即可进行可视化工作.我尝试了几个D3网络图,并在检查页面时对所有这些图得到了相同的错误.

I am new to D3 and Javascript but have typically had luck with just copying the basic D3 scripts and getting my data into the proper format for the visualization to work. I have tried several of the D3 Network graphs and have gotten the same error for all of them when I inspect the page.

未捕获的TypeError:无法读取未定义的属性'force'.

Uncaught TypeError: Cannot read property 'force' of undefined.

如果您在此处查看脚本: http://bl.ocks.org/jose187/4733747 我只是将其与相应的.json文件一起完全复制,并收到上述错误.似乎认为d3.layout.force()是一个匿名函数".有什么想法吗?或如何解决?谢谢!

If you look at the script here: http://bl.ocks.org/jose187/4733747 I just copied it completely along with the respective .json file and am getting the above error. It seems to think that d3.layout.force() is an "anonymous function". Any ideas what is going on? Or how to fix it? Thank you!

推荐答案

在D3 V4中,力量布局d3.layout.force已重命名为d3.forceSimulation.

The force layout d3.layout.force has been renamed to d3.forceSimulation in D3 V4 among many other changes.

有关更多信息,请参考此链接: D3 V4力

Refer to this link for more information: D3 V4 Force

这篇关于无法读取未定义的属性“力"(简单D3网络图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆