Skip to content

Instantly share code, notes, and snippets.

@mohhasbias
Last active February 26, 2017 04:17
Show Gist options
  • Save mohhasbias/6a0bb95540ce5578aac63cae02afc246 to your computer and use it in GitHub Desktop.
Save mohhasbias/6a0bb95540ce5578aac63cae02afc246 to your computer and use it in GitHub Desktop.
SVG line using D3
license: mit

Membuat SVG line elemen dengan menggunakan D3.

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<div id="d3-drawing-area"></div>
<script>
var svg = d3.select('#d3-drawing-area').append('svg')
.attr('width', 300)
.attr('height', 300)
.style('background', 'lightblue');
var line = svg.append('line')
.attr('x1', 100)
.attr('y1', 100)
.attr('x2', 200)
.attr('y2', 200)
.style('stroke', 'blue');
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment