The temporal unfolding of a controversial debate in psychology. Note I certainly do not condone all the positions uttered.
xxxxxxxxxx
<meta charset="utf-8">
<style>
div.tooltip {
position: absolute;
text-align: left;
width: 330px;
background-color: #ffffff;
padding: 3px 12px;
font-family: serif;
border: 1px solid #bbbbbb;
box-shadow: 1px 1px 4px #bbbbbb;
font-family: EB Garamond, serif;
text-transform: capitalize;
background: rgba(255,255,255, 0.9);
}
.links line {
stroke: #999;
stroke-opacity: 0.6;
}
.nodes circle {
stroke: #fff;
stroke-width: 1.5px;
}
.nodes circle:hover {
stroke: #ddd;
stroke-width: 1.5px;
}
a {
color: #108b99;
text-decoration: underline dotted;
}
h2 {
margin-top: 3pt;
margin-bottom: -5pt;
text-align: left;
font-family: 'Alegreya SC', serif;
font-size: 11pt;
font-weight: 300;
letter-spacing: 2.5px;
}
</style>
<body>
<svg width="960" height="600" ></svg>
</body>
<link type="text/css" href="index.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Alegreya|Alegreya+SC|Alegreya+Sans|Alegreya+Sans+SC|Cormorant+Garamond|Cormorant+SC:300,400,500,600,700|EB+Garamond|Fanwood+Text:400,400i|Goudy+Bookletter+1911|IM+Fell+Double+Pica+SC|IM+Fell+French+Canon+SC|IM+Fell+French+Canon:400,400i|IM+Fell+Great+Primer+SC|IM+Fell+Great+Primer:400,400i|Spectral+SC:200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i|Vollkorn+SC:400,600,700,900&subset=latin-ext" rel="stylesheet">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var color = d3.scaleOrdinal(d3.schemeCategory20);
var searchRadius = 40;
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
var simulation = d3.forceSimulation()
.force("link", d3.forceLink().id(function(d) { return d.id; }))
.force("charge", d3.forceManyBody().strength(-25))
.force("center", d3.forceCenter(width / 2, height / 1.5));
var tooltip = d3.select("body")
.append("div")
.attr("class", "tooltip")
.style("position", "absolute")
.style("z-index", "10")
.style("visibility", "hidden");
d3.json("race.json", function(error, graph) {
if (error) throw error;
var y = d3.scaleTime()
.domain([1971,2017])
.range([0, height]);
svg.append("g")
.call(d3.axisLeft(y));
// text label for the y axis
svg.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 0 )
.attr("x",0 - (height / 2))
.attr("dy", "1em")
.style("text-anchor", "middle")
.text("Value");
var link = svg.append("g")
.attr("class", "links")
.selectAll("line")
.data(graph.links)
.enter().append("line")
.attr("stroke-width", function(d) { return Math.sqrt(d.value); });
var node = svg.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(graph.nodes)
.enter().append("circle")
.attr("r", 5)
.attr("fill", function(d) { return color(d.cluster); })
.on("mouseover", function(d) {
div.transition()
.duration(200)
.style("opacity", .9)
/* div.html("<h2 >" + (d.label) + "</h2>" + "<p>" + (d.title) + "</p>" + "<p>" + (d.source)+ ", "+ (d.year))*/
div .html(
'<a href="'+(d.url ? d.url + "" : "")+'" target="_blank">' + "<h2 >" + (d.label) + "</h2>" + "</a>" + "<p>" + (d.title) + "</p>" + "<p>" + (d.source)+ ", "+ (d.year))
.style("left", (d3.event.pageX+30) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
div.transition()
.duration(6000)
.style("opacity", 0);
})
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended)) ;
node.append("title")
.text(function(d) { return d.id; });
simulation
.nodes(graph.nodes)
.on("tick", ticked);
simulation.force("link")
.links(graph.links);
function ticked() {
node.each(function(d) {
d.y = d.py = (d.year-1971)*10;
});
link
.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
node
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
}
});
function dragsubject() {
return simulation.find(d3.event.x - width / 2, d3.event.y - height / 2 , searchRadius);
}
function mousemoved() {
var a = this.parentNode, m = d3.mouse(this), d = simulation.find(m[0] - width / 2, m[1] - height / 2, 40);
if (!d) return a.removeAttribute("href"), a.removeAttribute("title"), tooltip.style('visibility','hidden');
a.setAttribute("href", "" + (d.url ? d.url + "" : ""));//+ d.id
a.setAttribute("title", d.id + (d.url ? " by " + d.url : "") + (d.description ? "\n" + d.description : ""));
loadTooltipThumb(d);
}
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
if (!d3.event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
</script>
https://d3js.org/d3.v4.min.js