Multiple Links Between Two Nodes in D3.js Force Directed Layout
A simple way to handle if there are multiple links between to nodes in the force directed layout implemented in D3.js.
HTML
<script type="text/javascript" src="https://d3js.org/d3.v2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<svg>
<circle r="5" cx="50" cy="50" id="thee"></circle>
</svg>
CSS
path.link {
fill: none;
stroke: #666;
stroke-width: 1.5px;
}
circle {
fill: #ccc;
stroke: #333;
stroke-width: 1.5px;
}
text {
font: 10px sans-serif;
pointer-events: none;
}
text.shadow {
stroke: #fff;
stroke-width: 3px;
stroke-opacity: .8;
}
body {
background-color: white;
margin: 0px;
}
.graphContainer {
text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white;
}
JavaScript
$('circle').on("click", function(d,i){
alert(d3.select(this).attr("id"))
})