Skip to content

Instantly share code, notes, and snippets.

Created February 9, 2018 14:26
fresh block
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<style>
.visualisation-container {
width: 100%;
height: 470px;
background-color: whitesmoke;
border: 1px solid black;
position: relative;
margin-top: 10px;
}
</style>
</head>
<body>
<br><br>
<div class="container">
<h5>
<u>Data Visualisation With D3 </u>
</h5>
<div id="my-container" class="visualisation-container"></div>
<br/>
<button class="btn btn-primary" id="trigger-animation"> Trigger Animation </button>
</div>
<script>
$(document).ready(() => {
//Your code goes here!
d3.select("#my-container")
.append('div')
.text('Hi there')
.style({
background: "rgba(255,0,0,0.1)",
border: "red 2px solid",
width: "100px",
height: "100px",
position: "absolute",
left: "300px",
top: "172px"})
;
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment