Last active
October 10, 2017 20:38
-
-
Save sriramveeraghanta/33f5a2003d0abddd2bd683ad6effdd6c to your computer and use it in GitHub Desktop.
Circle Swapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--transition.html--> | |
<html> | |
<head> | |
<title>D3 Tutorial</title> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
</head> | |
<body> | |
<script> | |
var width = 10000; | |
var height = 7500; | |
dataArray =[]; | |
var canvas = d3.select("body") | |
.append("svg") | |
.attr("width",width) | |
.attr("height",height); | |
var circle1 = canvas.append("circle") | |
.attr("r",200) | |
.attr("cx",1000) | |
.attr("cy",500) | |
.attr("fill","#EF6C00") | |
var circle2 = canvas.append("circle") | |
.attr("r",200) | |
.attr("cx",500) | |
.attr("cy",500) | |
.attr("fill","#2E3141") | |
circle1.transition() | |
.duration(1500) | |
.delay(1000) | |
.attr("cx",500) | |
.attr("cy",500) | |
.on("end",function(){d3.select(this).attr("fill","#2E3141")}); | |
circle2.transition() | |
.duration(1500) | |
.delay(1000) | |
.attr("cx",1000) | |
.attr("cy",500) | |
.on("end",function(){d3.select(this).attr("fill","#EF6C00")}); | |
circles = canvas.selectall("circle").data(dataArray) | |
.append("circle") | |
.exit() | |
.append("circle") | |
.transition() | |
.duration(1500) | |
.delay(1000) | |
.attr("cx",1000) | |
.attr("cy",500) | |
.each("end",function(){d3.select(this).attr("fill","#EF6C00")}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Circles Swapping code