Skip to content

Instantly share code, notes, and snippets.

@EE2dev
Last active April 17, 2018 22:30
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 EE2dev/6eb307fe936cb4017e154bf5a17af750 to your computer and use it in GitHub Desktop.
Save EE2dev/6eb307fe936cb4017e154bf5a17af750 to your computer and use it in GitHub Desktop.
Browser test 2
license: mit

browser window test.

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script src="https://d3js.org/d3.v5.min.js"></script>
<style>
body {
margin: 0;
}
div.chart {
position: relative;
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div class="chart"></div>
<script>
let chart = d3.select("div.chart");
const width = chart.style("width");
const height = chart.style("height");
console.log("w: " + width);
console.log("h: " + height);
let canvas = chart
.append('canvas')
.attr('width', width)
.attr('height', height);
var context = canvas.node().getContext('2d');
context.fillStyle = "steelblue";
// context.fillRect(0, 0, width, height);
context.fillRect(10, 10, 200, 200);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment