d3.js在缩放时,如何使它不影响节点的大小?

时间:2013-10-01 01:54:13

标签: d3.js zooming

当我放大力图时,我想忽略节点,因为我是链接和文本。我很难搞清楚如何。 (我使用不同的SVG形状,所以我无法缩放“r”。)这是我的节点代码:

    //node declared as global
    node = svg.selectAll(".node")
        .data(force.nodes()).enter().append("path")
        .attr("class", "node")
        .attr("d", d3.svg.symbol().type(function (d) { return d.Shape; }).size(150))

缩放代码:

    function redraw(scale, trans) {
        //store the last event data
        trans = d3.event.translate;
        scale = d3.event.scale;

        text.style("font-size", (fontSize / scale) + "px");
        textEvidenceCtr.style("font-size", (fontSize / scale) + "px");
        $("line.link").css("stroke-width", getStrokeWidth); // Function so it runs for each element individually

        //transform the vis
        svg.attr("transform",
           "translate(" + trans + ")"
           + " scale(" + scale + ")"); }

谢谢!

0 个答案:

没有答案