Skip to content

Instantly share code, notes, and snippets.

@mathisonian
Created January 27, 2016 03:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathisonian/42a4adf305916a9174f8 to your computer and use it in GitHub Desktop.
Save mathisonian/42a4adf305916a9174f8 to your computer and use it in GitHub Desktop.
var aspectRatio= '16:9'
var svg = d3.select('#example-4')
.append('svg')
.attr('width', '100%')
.attr('viewBox', '0 0 ' + aspectRatio.split(':').join(' '));
// draw a rect to act as an outline
svg.append('rect')
.style('fill', 'orange')
.attr('width', '100%')
.attr('height', '100%');
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<div id="example-4" style="max-width: 800px;"></div>
<script type="text/javascript" src="./app.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment