ArtPoon/BioID

Draw rectangular layout of rooted tree

Closed this issue · 3 comments

I've got this working for the initial draw, but it's not updating with the points.
grab1
grab2

Initial draw:

  // draw points
  svg2.selectAll(".dot")
      .data(nodes)
      .enter().append("circle")
      .attr("class", "dot")
      .attr("r", 5)
      .attr("cx", x2Map)
      .attr("cy", y2Map)
      .attr("stroke", "black")
      .attr("stroke-width", 2)
      .attr("fill", "white");

  // draw lines
  svg2.selectAll("lines")
      .data(rootedEdges)
      .enter().append("line")
      .attr("x1", x2Map1)
      .attr("y1", y2Map1)
      .attr("x2", x2Map2)
      .attr("y2", y2Map2)
      .attr("stroke-width", 3)
      .attr("stroke", "#777");

Refresh:

  svg2.selectAll(".dot")
      .data(nodes)
      .transition().duration(100)
      .attr("cx", x2Map)
      .attr("cy", y2Map);

  svg2.selectAll("lines")
      .data(rootedEdges)
      .transition().duration(100)
      .attr("x1", x2Map1)
      .attr("y1", y2Map1)
      .attr("x2", x2Map2)
      .attr("y2", y2Map2);

rootedEdges is definitely getting updated as the user relocates the root.

The problem was that lines wasn't selecting the line segments -- it has to be svg2.selectAll(".lines").