This is Bostock's reusable chart pattern stripped to the bare bones. It includes enter/update/exit, loads of comments and even a tooltip (the pants - easily stripped off, too).
Built with blockbuilder.org
xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>mnml reusable</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.2/lodash.min.js"></script>
<link rel="stylesheet" href="reusable.css">
</head>
<body>
<style type="text/css">
</style>
<div class="container"></div>
<button id="sort1">sort by rating</button>
<button id="sort2">sort by film</button>
<div class="tooltip"></div>
<script src="reusable.js"></script>
</body>
</html>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js
https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.2/lodash.min.js