TypeError: undefined is not an object (evaluating 'M.layout.force')
TypeError: undefined is not an object (evaluating 'M.layout.force')
我是 JSNetworkX 的新手。我使用 jsnetworkx.org 中的示例创建了一个图表,但我只能记录它,无法显示它。
所以这是 index.html
文件:
<html>
<head>
<script src="https://d3js.org/d3.v4.js"></script>
<script src="jsnetworkx.js"></script>
</head>
<body>
<script src = "script.js"></script>
</body>
</html>
这是 script.js
中编写的代码:
var G = jsnx.completeGraph(6);
console.log(G.nodes());
jsnx.draw(G, {
element: 'body',
weighted: true,
edgeStyle: {
'stroke-width': 10
}
});
这是输出:[0, 1, 2, 3, 4, 5]
这是我得到的错误:
JSNetworkX error - TypeError: undefined is not an object (evaluating 'M.layout.force')
问题是包含最新版本的 D3.js。
改变
<script src="https://d3js.org/d3.v4.js"></script>
到
<script src="https://d3js.org/d3.v3.js"></script>
会修复它。
我是 JSNetworkX 的新手。我使用 jsnetworkx.org 中的示例创建了一个图表,但我只能记录它,无法显示它。
所以这是 index.html
文件:
<html>
<head>
<script src="https://d3js.org/d3.v4.js"></script>
<script src="jsnetworkx.js"></script>
</head>
<body>
<script src = "script.js"></script>
</body>
</html>
这是 script.js
中编写的代码:
var G = jsnx.completeGraph(6);
console.log(G.nodes());
jsnx.draw(G, {
element: 'body',
weighted: true,
edgeStyle: {
'stroke-width': 10
}
});
这是输出:[0, 1, 2, 3, 4, 5]
这是我得到的错误:
JSNetworkX error - TypeError: undefined is not an object (evaluating 'M.layout.force')
问题是包含最新版本的 D3.js。
改变
<script src="https://d3js.org/d3.v4.js"></script>
到
<script src="https://d3js.org/d3.v3.js"></script>
会修复它。