Syntax for axis transition in svg/d3

后端 未结 1 1074
再見小時候
再見小時候 2021-01-01 21:34

I\'ve an incredibly basic syntax question. I\'ve been learning d3, SVG, and Javascript mostly by editing someone else\'s code, which is challenging.

The goal is to u

相关标签:
1条回答
  • 2021-01-01 22:35

    Following meetamit's suggestions and the example here, I have stumbled on what appears to be a solution.

    First, in function makeYaxis(), I removed the line .append("g"). I also updated the class name to yaxis. The function now reads

    function makeYaxis (chart, scale, nticks, label, width, height, xmf, visName)
    {
        var yAxis = d3.svg.axis()
        .scale(scale)
        .orient("left")
        .ticks(nticks);
        chart.append("svg:g")
        .attr("class","yaxis") // note new class name
    //  .append("g")
        .attr("transform","translate(60,1)") 
        .call(yAxis);
        // everything else as before
    }

    I then added an extra period in my call to select(".yaxis"):

    chart.select(".yaxis").transition().duration(10).call(yAxis);
    

    I would be very grateful if anyone could explain to me exactly why this solution appears to work.

    0 讨论(0)
提交回复
热议问题