d3.js - Fix only one dimension of a node in force layout? -


this question - fix node position in d3 force-directed layout - covers how fix position of node in force-layout.

my question how fix 1 dimension, x or y, of node , let other respond forces in layout.

this isn't directly supported in d3, can manually resetting coordinate want remain constant in tick handler function.

force.on("tick", function() {   nodes.each(function(d) {     d.x = d.px = d.savedx; // similar y   });   // other stuff }); 

this requires store desired value data bound nodes, in example in attribute savedx (although can use other name long it's not used else).


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -