我只是按照felix-kling上的示例进行操作。但它只是抱怨Uncaught TypeError: Cannot read property 'getComputedStyle' of null
。我正在使用 chrome。当我从anotherOne复制示例时,也会发生同样的错误。有什么想法吗?
<!DOCTYPE html>
<html>
<head>
<title>JSNetworkX images as nodes demo</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="jsnetworkx.js"></script>
</head>
<body>
<div id="canvas"></div>
<script type="text/javascript">
var G = jsnx.Graph();
G.add_nodes_from([
[1,{color:'red'}],
[2,{color:'green'}],
[3,{color:'white'}]
]);
G.add_edges_from([[1,2],[1,3]]);
jsnx.draw(G,{
element: '#demo-canvas',
node_style: {
fill: function(d) {return d.data.color || '#AAA';}
}
});
</script>
</body>
</html>