score:1

Accepted answer

Instead of doing

myChart.transition().
    attr("height", function (d) {
        return yScale(d);
    }).
    attr("y", function (d) {
        return(h-yScale(d));
    })

The above is wrong since you are giving transition to svg. Here myChart is the SVG.

You should be doing the same on the rectangle or the bars as shown below.

rects.transition().
    attr("height", function (d) {
        return yScale(d);
    }).
    attr("y", function (d) {
        return(h-yScale(d));
    })

working code here


Related Query

More Query from same tag