Adding axis to a bar chart in D3

I’m trying to add the axis to my bar chart and transform my bar chart horizontal view to a vertical one. This is my chart:

<!DOCTYPE html>
        <script src=""></script>
    // Append svg space
    d3.json("csvjson.json", function (data) {
        var canvas ="body").append("svg")
        .attr("width", 1500)
        .attr("height", 1500)
//Drawing bar chart
            .attr("width", function(d) {return d.Rhinos;})
            .attr("height", 50)
            .attr("y", function (d, i) {return i*60})
            .attr("fill", "gray");
//Add text to the bars
            .attr("fill", "black")
            .attr("y", function (d, i) {return i*60+25;})
            .text(function (d) {return d.Rhinos})
//Add scale
var scale = d3.scaleLinear()
            .domain([d3.min(data), d3.max(data)])
            .range([0, 1500]);

var g = svg.selectAll("g")
        .attr("transform", function (d, i){
            return "translate(0,"+i*height +")";

        .attr("width", function (d) {
               return scale(d);
        .attr("height", height - margin)

        .attr("x", function (d) { return (scale(d)); })
        .attr("y", height / 2)
        .attr("dy", ".35em")
        .text(function (d) { return d; });
 Run code sni

What is wrong with this code? How to add an axis? The code runs fluently until cell 31. After that I added the scaling and axis. And it doesn’t work. Thank you in advance!