Vivagraph.js でノードの位置を取得するために、次のコードを試しました。未定義を返す理由がわかりません。
console.dir(node) を実行すると、位置が設定されていることがわかりますが、何らかの理由でアクセスできません。
var layout = Viva.Graph.Layout.forceDirected(graph, {
springLength : 20,
springCoeff : 0.0008,
dragCoeff : 0.1,
gravity : -10,
theta : 0.5
});
var graphics = Viva.Graph.View.webglGraphics();
var nodeSize = 10;
graphics.setNodeProgram(Viva.Graph.View.webglImageNodeProgram());
graphics.node(function(node) {
//url location on your server
var ui = Viva.Graph.View.webglImage(nodeSize, 'https://lh4.googleusercontent.com/' + node.data);
console.dir(ui);
return ui;
}).link(function(link) {
return Viva.Graph.View.webglLine(colors[(Math.random() * colors.length) << 0]);
});
graph.forEachNode(function(node) {
console.log('pos ' + node.position);
});