3 // "label": "Dairy Milk",
16 function SGND3ScatterPlot(data, div_id, x_label) {
27 var colors = d3.scale.category10();
29 var svg = d3.select("#"+div_id).append("svg").attr("width", width).attr("height", height).append("g")
30 .attr("transform", "translate(" + margins.left + "," + margins.top + ")");
32 var x = d3.scale.linear()
33 .domain(d3.extent(data, function (d) {
36 .range([0, width - margins.left - margins.right]);
38 var y = d3.scale.linear()
39 .domain(d3.extent(data, function (d) {
42 .range([height - margins.top - margins.bottom, 0]);
44 svg.append("g").attr("class", "x axis").attr("transform", "translate(0," + y.range()[0] + ")");
45 svg.append("g").attr("class", "y axis");
48 .attr("fill", "#414241")
49 .attr("text-anchor", "end")
51 .attr("y", height - 35)
54 var xAxis = d3.svg.axis().scale(x).orient("bottom").tickPadding(2);
55 var yAxis = d3.svg.axis().scale(y).orient("left").tickPadding(2);
57 svg.selectAll("g.y.axis").call(yAxis);
58 svg.selectAll("g.x.axis").call(xAxis);
60 var valInd = svg.selectAll("g.node").data(data, function (d) {
64 var valGroup = valInd.enter().append("g").attr("class", "node")
65 .attr('transform', function (d) {
66 return "translate(" + x(d.x_pos) + "," + y(d.y_pos) + ")";
69 valGroup.append("circle")
72 .style("fill", function (d) {
73 return colors(d.type);
76 valGroup.append("text")
77 .style("text-anchor", "middle")