javascript - D3.js: Factoring zoom/scale into a multiselect box -


i have graph allows zooming in , out on different nodes. aid in selecting multiple nodes, have integrated drag-selection box shown here: http://bl.ocks.org/lgersman/5370827. works when user has not zoomed out of graph, once do, becomes skewed.

i know need take scale account, not sure factoring in. scale value goes 1 (no zoom) .1 (zoomed way out). below snippet scale adjustment should go. have tried multiplying it, adding both size of box , x/y, have not identified best spot.

var d = {     x       : parseint(s.attr("x"), 10),     y       : parseint(s.attr("y"), 10),     width   : parseint(s.attr("width"), 10),     height  : parseint(s.attr("height"), 10) }, move = {     x : p[0] - d.x,     y : p[1] - d.y       } ;  if( move.x < 1 || (move.x*2<d.width)) { //dragging left     d.x = p[0];     d.width -= move.x; } else { //dragging right     d.width = move.x;        }  if( move.y < 1 || (move.y*2<d.height)) { //dragging     d.y = p[1];     d.height -= move.y; } else { //dragging down     d.height = move.y;        }  s.attr(d); 


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -