Thursday, 15 July 2010

d3.js - D3/SVG: Why is this code slower when selection is changed? -


I have a group selection that passed this function which I used to use this group.addend ("path") Make a call. Blah.blah It is incredibly slow, maybe 100 times the slowest can not tell this because 2V is delayed, but the SVG shown below is used immediately. Append is being used immediately. Can anyone tell me why? Although it works, I have to repeat the translation that I had already done for the group and it is preparing to order my SVG element.

This way my node group has been declared

  var node group = svg.selectAll ("g") .data (listNodes). Enter () endend ("g") .attr ("id", function (d) {returns "group_" + trim white space (d);}). Etiquette ("Transform", "Transform (580,260)");   

and how svg is declared

  var svg = d3.select ("# container") .append ("svg") .attr ( "Id", "svgcontainer") .attr ("viewbox", "0 1300 610") .attr ("perserve aspectratio", "xMinYMid") .attr ("width", w + margin.left + margin.right ) .attr ("height", H + margin.Top + margin.bottom) .Append ("g") .attr ("conversion", "translation (" + margin left. "," + Margin.Top + " ) ");    

What are you trying to do? Personally, I consider it a bad form to mix loop with d3.js; D3 data binding is usually a better way of working compared to the loop.

Go back to your question, when you change the node group with STVG, you basically repeat the loop listNodes.length times (ListNodes.length x listEdges.length executions List.Engges.length instead).

Perhaps you should expand on what you are trying to do?

No comments:

Post a Comment