2016-01-21 60 views
2

我使用d3繪製圖表(我使用的是thix示例:https://gist.github.com/keiranlovett/8766741)。我需要添加一個鏈接。我添加文字,我試圖讓一個鏈接,但它不會顯示爲一個鏈接(我使用的是IE 11):使文本成爲svg中的鏈接

svg.append("g") //without doing this, impossible to put grid lines behind text 

    .attr({ 
      xmlns: "http://www.w3.org/2000/svg", 
      xlink: "http://www.w3.org/1999/xlink", 
      width: 100, 
      height: 300 
     }) 
    .attr({ "xlink:href": "#" }) 
    .on("mouseover", function (d, i) { 
      //alert('aaa'); 
      d3.select(this) 
       .attr({ "xlink:href": "http://example.com/" + "eeeeeeeeeeeeeeeeeee" }); 
     }) 
    .selectAll("text") 

    .data(tasks) 
    .enter() 
    .append("text") 

    .text(function (d) { 
     if (ammendmentsLinks.indexOf(d.contract) < 0) { 
      ammendmentsLinks = ammendmentsLinks + d.contract + ";"; 
      return d.contract; 
      //return ""; 
     } 
     else { 
      return ""; 
     } 
    }) 
    .attr("x", 20) 
    .attr("y", function (d, i) { 
     return i * 20; 
    }) 
    .attr("font-size", 11) 
    .attr("text-anchor", "start") 
    .attr("text-height", 14) 
    .on("click", function (d) { 
     return click(d.contract); 
    }); 

我還添加了一些代碼行從http://jsfiddle.net/christopheviau/B9zcF/使文本鏈接,但它不工作。

如何讓我的文本鏈接?

回答