var xScale = d3.scale.linear() .domain([0, d3.max(dataset, function(d){return d[0];})]) .range([0, w]); var yScale = d3.scale.linear() .domain([0, d3.max(dataset, function(d){return d[1];})]) .range([h, 0]);
.attr("cx", function(d) { return xScale(d[0]); }).attr("cy", function(d) { return yScale(d[1]); })
.attr("x", function(d) { return xScale(d[0]) + 3; }).attr("y", function(d) { return yScale(d[1]) + 3 * 2; })
Margin Convention、Multi-Value Maps
var padding = {top: 20, right: 60, bottom: 20, left: 10};
var xScaleN3 = d3.scale.linear() .domain([0, d3.max(dataset, function(d) { return d[0]; })]) .range([padding.left, w - padding.right]); var yScaleN3 = d3.scale.linear() .domain([0, d3.max(dataset, function(d) { return d[1]; })]) .range([h - padding.bottom, padding.top]);