var data = [ [5,2], [15,20], [18,24], [28,32], [35,40], [58,69] ]; var xScale = d3.scale.linear() .domain(d3.extent(data, function(d) { return d[0]})) .range([0, 600]); //The width var yScale = d3.scale.linear() .domain(d3.extent(data, function(d) { return d[1]})) .range([0, 550]); //The height //Create x- axis var xAxis = d3.svg.axis() .scale(xScale) //pass scale .orient("bottom"); //orient axis horizontal //Plot axis as d3.select("svg") .append("g") .call(xAxis); //Pass created axis //Create Y-axis var yAxis = d3.svg.axis() .scale(yScale) //pass scale .orient("left"); //orient axis verticle //Plot axis as d3.select("svg") .append("g") .call(yAxis); //Pass created axis
<br> <br> <svg width="600" height="550"></svg>