Skip to content

Instantly share code, notes, and snippets.

@kristw
Last active October 17, 2016 13:51
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 kristw/2cc83b10a1677a16f6448a5108b322a1 to your computer and use it in GitHub Desktop.
Save kristw/2cc83b10a1677a16f6448a5108b322a1 to your computer and use it in GitHub Desktop.
Using d3Kit to scaffold <canvas>
license: mit

Create a scaffold from d3Kit CanvasChart.

<!DOCTYPE html>
<title>blockup</title>
<link href='style.css' rel='stylesheet' />
<body>
<div id="chart"></div>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://rawgit.com/twitter/d3kit/v3/dist/d3kit.min.js"></script>
<script src='main.js'></script>
</body>
var chart = new d3Kit.CanvasChart('#chart', {
initialWidth: 720,
initialHeight: 500,
margin: { top: 30, right: 30, bottom: 30, left: 30 }
});
var ctx = chart.getContext2d();
ctx.fillStyle = 'red';
ctx.fillRect(10, 10, chart.getInnerWidth(), chart.getInnerHeight());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment