2015-10-20 53 views
0

我已將文字和(圖形)添加到了我的陽光中心,並且我想在放大時隱藏它。如何在縮放時「隱藏」d3可縮放朝陽中心的文字?

  svg.append("image") 
        .attr("xlink:href", "scholarWorksDark.png") 
        .attr("x", -80) 
        .attr("y", -150) 
        .attr("width", "150") 
        .attr("height", "150"); 
        //.on("click", click(d)); 


     svg.append("text") 
      //.on("click",click) 
      .attr("x", -115) 
      .attr("y", 90) 
      .style("font-size",16) 
      //.style("font-weight","bold") 
      .html("Click to explore our <br/><br/>" + hierarchy.value + " ETDs"); 

正如你可以在我的plunk

看到當我點擊文本仍然可見旭日的部分,我只希望它表明,當它在「家」的狀態。

回答

0

回答關於谷歌D3組: 需要在一個類添加到中央的文字:

svg.append("text") 
      //.on("click",click) 
      .attr("class","center-text") 
      .attr("x", -115) 
     .attr("y", 90) 
      .style("font-size",16) 
      //.style("font-weight","bold") 
      .html("Click to explore our <br/><br/>" + hierarchy.value + " ETDs"); 

     function click(d) { 
      path.transition() 
       .duration(750) 
       .attrTween("d", arcTween(d)); 
      if(d.key !== "ETD"){ 
       svg.select(".center-text") 
       .style("display","none") 
      } else { 
       svg.select(".center-text") 
       .style("display","") 
      } 
      mouseout(); 
     };