Built with blockbuilder.org
xxxxxxxxxx
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>ScatterPlot Chart</title>
<style>
.axis path,
.axis line{
fill: none;
stroke: black;
}
.tick text{
font-size: 12px;
}
circle {
fill: orange;
}
</style>
</head>
<body>
<script src="https://d3js.org/d3.v3.js"></script>
<script>
var margin = {top: 20, right: 100, bottom: 30, left: 100},
width = 1050 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
d3.csv("graduates.csv", function(error, data) {
if (error) throw error;
data.forEach(function(d) {
d.x = d.Employed;
d.y = d.Masters;
});
var xScale = d3.scale.linear()
.domain([0, d3.max(data, function(d){ return d.x; })])
.range([0, width]);
var yScale = d3.scale.linear()
.domain([0, d3.max(data, function(d){ return d.y/100; })])
.range([height, 0]);
var xAxis = d3.svg.axis().scale(xScale).orient("bottom");
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left");
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.append("text")
.attr("x", 900)
.attr("dx", "-4em")
.attr("text-anchor", "end")
.text("Employed Student");
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 7)
.attr("dy", "-4em")
.attr("text-anchor", "end")
.text("Masters Student");
svg.selectAll("scatter-dots")
.data(data)
.enter().append("svg:circle")
.attr("cx", function (d) { return xScale(d.x); } )
.attr("cy", function (d) { return yScale(d.y); } )
.attr("r", 3);
});
</script>
</body>
</html>
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js