Skip to content

Instantly share code, notes, and snippets.

@isomorphisms
Last active November 24, 2017 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isomorphisms/17477fdabe5dc8cd0fb16d12577c6566 to your computer and use it in GitHub Desktop.
Save isomorphisms/17477fdabe5dc8cd0fb16d12577c6566 to your computer and use it in GitHub Desktop.
barcodes of constant width at random intervals in D3
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
d3.select("svg").selectAll("rect").data(["1em","5em","7em","13em"]).enter().append("rect").attr("x", (d) => { return d; })
</script>
<style>
html {
background-color: #333;
color: #ccc;
font-family: "Courier New";
margin: 3em;
margin-top: 0;
}
</style>
<title>bar codes</title>
</head>
<body>
<h1>bar codes</h1>
<svg width="20em" height="10em">
<rect x=0 y="0" height="5em" width="1em" style="fill:#eee"></rect>
</svg>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment