For continuous data such as time series, a streamgraph can be used in place of stacked bars. This example also demonstrates path transitions to interpolate between different layouts. Streamgraph algorithm, colors, and data generation inspired by Byron and Wattenberg.
forked from mbostock's block: Streamgraph
forked from dymzd's block: Streamgraph
xxxxxxxxxx
<head>
<meta charset="utf-8">
<title>Streamgraph</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="//d3js.org/d3-scale-chromatic.v0.3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
h1,h2,p {
margin:0px;
}
svg {
width="800"
height="400";
id="svg";
margin-top:-40px;
}
div.tooltip {
position: absolute;
text-align: center;
width: 100px;
height: 40px;
padding: 2px;
font: 12px sans-serif;
background: white;
border: 0px;
border-radius: 8px;
pointer-events: none;
}
</style>
<h1>Trend Scores over time 2004-2018</h1>
<h2 id="major">Mouse Over</h2>
</head>
<body>
<div id="graph"></div>
<script src="script.js"></script>
</body>
https://d3js.org/d3.v4.min.js
https://d3js.org/d3-scale-chromatic.v0.3.min.js