block by NPashaP fcb09e2cddbe104e209f457d44f166ca

biPartite - Linking Multiple biPartites

Full Screen

This example shows how multiple biPartite graphs from same data can be linked so that mouseover and mouseout transitions both.

For more examples, check VizJS

index.html

<!DOCTYPE html>
<meta charset="utf-8">
<style>
.mainBars{
  shape-rendering: auto;
  fill-opacity: 0;
  stroke-width: 0.5px;
  stroke: rgb(0, 0, 0);
  stroke-opacity: 0;
}
.subBars{
	shape-rendering:crispEdges;
}
.edges{
	stroke:none;
	fill-opacity:0.3;
}
</style>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="//vizjs.org/viz.v1.1.0.min.js"></script>
<script>
var _data=[
['A','X', 1, 5]
,['A','Y', 3,4]
,['B','X', 5,1]
,['B','Y', 8,10]
,['C','X', 2,13]
,['C','Y', 9,7]
];

var color = {A:"#3366CC", B:"#DC3912",  C:"#FF9900"};
var svg = d3.select("body").append("svg").attr("width", 960).attr("height", 500);
var g1 = svg.append("g").attr("transform","translate(50,50)");
var bp1=viz.bP()
			.data(_data)
			.min(10)
			.pad(1)
			.height(400)
			.width(200)
			.barSize(35)
			.fill(d=>color[d.primary]);
			
g1.call(bp1);

var g2 = svg.append("g").attr("transform","translate(350,50)");
var bp2=viz.bP()
			.data(_data)
			.value(d=>d[3])
			.min(10)
			.pad(1)
			.height(400)
			.width(200)
			.barSize(35)
			.edgeMode("straight")
			.fill(d=>color[d.primary]);
			
g2.call(bp2);

g1.selectAll(".mainBars")
	.on("mouseover",mouseover)
	.on("mouseout",mouseout);

g2.selectAll(".mainBars")
	.on("mouseover",mouseover)
	.on("mouseout",mouseout);

function mouseover(d){
	bp1.mouseover(d);
	bp2.mouseover(d);
}	

function mouseout(d){
	bp1.mouseout(d);
	bp2.mouseout(d);
}	
</script>
</body>
</html>