且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

d3.js强制图 - 图像/节点链接和动画

更新时间:2023-01-26 08:47:54

I've enhanced the system to take an array of user information. This is then used to build the nodes.

*Latest Code http://jsfiddle.net/LsMZp/49/ *

http://jsfiddle.net/LsMZp/26/

the remaining issues here.

  • the need to remove nomad nodes - if user's share the same interest - they link as expected - but this leads an additional node - is there a way to clear this up during node construction - or should duplicate nodeId's be removed before rendering?
  • the user images appear to be split in quadrants as if they are not centred properly, not sure why here is the code

x and y are set to 0.

 $.each(userData, function( index, value ) {
        var defs = patternsSvg.append('svg:defs');
                    defs.append('svg:pattern')
                        .attr('id', "--"+index+"-"+value.userName.toLowerCase())
                        .attr('patternUnits', 'userSpaceOnUse')
                        .attr('width', 100)
                        .attr('height',100)
                        .append('svg:image')
                        .attr('xlink:href', value.userImage)
                        .attr('x', 0)
                        .attr('y', 0)
                        .attr('width', 100)
                        .attr('height', 100);

    });