A simple example to show how to create a basic vertical and horizontal biPartite visualization. Hover over a bar for transition.
Part of a series of examples on biPartite graphs: Example II, Example III, Example IV, Example V
license: gpl-3.0 |
A simple example to show how to create a basic vertical and horizontal biPartite visualization. Hover over a bar for transition.
Part of a series of examples on biPartite graphs: Example II, Example III, Example IV, Example V
<!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="http://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 color1 = {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(2) | |
.height(400) | |
.width(200) | |
.barSize(35) | |
.orient("vertical") | |
.edgeMode("straight") | |
.fill(d=>color1[d.primary]); | |
g1.call(bp1); | |
var color2 = {X:"rgb(56,43,61)", Y:"rgb(241,47,55)"}; | |
var g2 = svg.append("g").attr("transform","translate(350,150)"); | |
var bp2=viz.bP() | |
.data(_data) | |
.keyPrimary(d=>d[0]) | |
.keySecondary(d=>d[1]) | |
.value(d=>d[2]) | |
.min(10) | |
.pad(1) | |
.height(200) | |
.width(400) | |
.barSize(35) | |
.orient("horizontal") | |
.fill(d=>color2[d.secondary]); | |
g2.call(bp2); | |
</script> | |
</body> | |
</html> |