An implementation in D3 of Figure 5-13 "Interactive stacked bar chart in Protovis" in "Visualize This" by Nathan Yau.
The implementation of this chart is quite like the one in the book, as both Protovis and D3 were created by Mike Bostock.
xxxxxxxxxx
<body>
<style>
body {
width: 100%;
font-family: Georgia;
font-size: 14px;
color: #333;
}
#container {
width: 500px;
margin: 0 auto;
position: relative;
}
#header h1 {
text-transform: uppercase;
font-size: 18px;
}
#header {
line-height: 1.4em;
margin-bottom: 16px;
}
.bar {
font-family: Arial;
font-size: 12px;
shape-rendering: crispEdges;
}
.x.axis path {
stroke-width: 2;
}
.y.axis path {
stroke-width: 0
}
.y.axis line {
stroke: #aaa;
stroke-width: 2;
}
.legend {
fill: #000;
font-style: italic;
}
</style>
<div id="container">
<div id="header">
<h1>Approval ratings for Barack Obama</h1>
Recent Gallup and CBS polls show a 52% approval rating for Barack Obama in race relations. It is the only issue out of the
below thirteen where he has a majority approval. In eight of the thirteen, results show a majority disapproval.
</div>
</div>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="app.js"></script>
</body>
https://d3js.org/d3.v4.min.js