|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Visualization of Publications on Machine Learning for Source Code |
| 4 | +description: A tSNE visualization of all the ML4Code papers |
| 5 | +--- |
| 6 | +<h2>2D Map of Papers</h2> |
| 7 | +Each dot represents one paper in this survey. Hover your mouse over each point to look |
| 8 | +at the details. Click on a point to go to the paper information page. |
| 9 | +<div id="paperviz"></div> |
| 10 | + |
| 11 | +Please consider <a href="/contributing.html">contributing</a> by updating |
| 12 | +the information of existing papers or adding new work. |
| 13 | + |
| 14 | +<script src=" https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.js" ></script> |
| 15 | +<script src="https://cdn.jsdelivr.net/npm/tippy.js@6/dist/tippy.umd.min.js"></script> |
| 16 | +<script src="https://d3js.org/d3.v4.js"></script> |
| 17 | + |
| 18 | +<script> |
| 19 | +// set the dimensions and margins of the graph |
| 20 | +var margin = {top: 10, right: 30, bottom: 30, left: 60}, |
| 21 | + width = 600 - margin.left - margin.right, |
| 22 | + height = 500 - margin.top - margin.bottom; |
| 23 | + |
| 24 | +var svg = d3.select("#paperviz") |
| 25 | + .append("svg") |
| 26 | + .attr("width", width + margin.left + margin.right) |
| 27 | + .attr("height", height + margin.top + margin.bottom); |
| 28 | + |
| 29 | +//Read the data |
| 30 | +d3.json("./etc/tsne.json", function(data) { |
| 31 | + // Add X axis |
| 32 | + var x = d3.scaleLinear() |
| 33 | + .domain([-15, 15]) |
| 34 | + .range([ 0, width ]); |
| 35 | + |
| 36 | + // Add Y axisB |
| 37 | + var y = d3.scaleLinear() |
| 38 | + .domain([-15, 15]) |
| 39 | + .range([height, 0]); |
| 40 | + |
| 41 | + // Add a tooltip div. Here I define the general feature of the tooltip: stuff that do not depend on the data point. |
| 42 | + // Its opacity is set to 0: we don't see it by default. |
| 43 | + var tooltip = d3.select("#paperviz") |
| 44 | + .append("div") |
| 45 | + .style("opacity", 0) |
| 46 | + .attr("class", "tooltip") |
| 47 | + .style("background-color", "rgb(81, 81, 81)") |
| 48 | + .style("width", "450px") |
| 49 | + .style("height", "120px") |
| 50 | + .style("color", "white") |
| 51 | + .style("border-width", "0px") |
| 52 | + .style("border-radius", "10px") |
| 53 | + .style("padding", "10px") |
| 54 | + .style("position", "absolute"); |
| 55 | + |
| 56 | + // A function that change this tooltip when the user hover a point. |
| 57 | + // Its opacity is set to 1: we can now see it. Plus it set the text and position of tooltip depending on the datapoint (d) |
| 58 | + var mouseover = function(d) { |
| 59 | + tooltip |
| 60 | + .style("opacity", 1) |
| 61 | + } |
| 62 | + |
| 63 | + var mousemove = function(d) { |
| 64 | + tags = "" |
| 65 | + for (i=0; i<d.tags.length; i++) { |
| 66 | + tags += "<tag>" + d.tags[i] + "</tag> " |
| 67 | + } |
| 68 | + tooltip |
| 69 | + .html("<p>" + d.title + " " + tags + "</p>") |
| 70 | + .style("left", (d3.mouse(this)[0]+40) + "px") |
| 71 | + .style("top", (d3.mouse(this)[1]) + "px"); |
| 72 | + d3.selectAll("circle").filter(dd => dd.key == d.key).style("fill", "#000"); |
| 73 | + } |
| 74 | + |
| 75 | + var mouseleave = function(d) { |
| 76 | + //tooltip |
| 77 | + // .transition() |
| 78 | + // .duration(300) |
| 79 | + // .style("opacity", 0) |
| 80 | + d3.selectAll("circle").filter(dd => dd.key == d.key).style("fill", "#69b3a2"); |
| 81 | + } |
| 82 | + |
| 83 | + var click_link = function(d) { |
| 84 | + window.location.href = "/publications/" + d.key + "/"; |
| 85 | + } |
| 86 | + |
| 87 | + // Add dots |
| 88 | + svg.append('g') |
| 89 | + .selectAll("dot") |
| 90 | + .data(data) |
| 91 | + .enter() |
| 92 | + .append("circle") |
| 93 | + .attr("cx", function (d) { return x(d.tsne_embedding[0]); } ) |
| 94 | + .attr("cy", function (d) { return y(d.tsne_embedding[1]); } ) |
| 95 | + .attr("r", 8) |
| 96 | + .style("fill", "#69b3a2") |
| 97 | + .style("opacity", 0.4) |
| 98 | + .style("stroke", "white") |
| 99 | + .on("mouseover", mouseover ) |
| 100 | + .on("mousemove", mousemove ) |
| 101 | + .on("mouseleave", mouseleave ) |
| 102 | + .on("click", click_link) |
| 103 | + |
| 104 | +}); |
| 105 | +</script> |
0 commit comments