javascript - The d3 force layout central node positioning -
i have use d3.js visualize data. , result this.
pic_1

pic_2

my question how can make data present pic_1,the center point local in fixed position,and other points (children points) around center point circle.
now,when refresh page data reload in brower , points' position randomly change well.
so d3's api or tricks can used purpose. :)
take @ example:

if exampne code, , play layout, you'll see root node has special treatment makes remain in center of graph (unless drag it, can prevent if want).
on initialization, property fixed set true, d3 force layout simulation doesn't move it. also, placed in center of rectangle containing layout:
root.fixed = true; root.x = width / 2; root.y = height / 2; you ofcourse need change or add code in order integrate feature example, core idea clear example linked.
hope helps. let me know if have question, need clarification, etc.
Comments
Post a Comment