Created
March 2, 2017 21:22
-
-
Save capitolmuckrakr/c6a22e4476c674f54f55166e0510dfa5 to your computer and use it in GitHub Desktop.
Revisions
-
capitolmuckrakr created this gist
Mar 2, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ license: gpl-3.0 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/ad550c9d6d156ac726b45f48fa6ff2c7'>I Make Circles</a> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ <!DOCTYPE html> <style> button { position: absolute; top: 10px; left: 10px; } circle { fill: none; stroke: #000; stroke-width: 1.5px; } </style> <button>Click Me</button> <svg width="960" height="500"></svg> <script src="https://d3js.org/d3.v4.min.js"></script> <script> var svg = d3.select("svg"), margin = {top: 30, right: 30, bottom: 30, left: 30}, width = +svg.attr("width") - margin.left - margin.right, height = +svg.attr("height") - margin.top - margin.bottom, g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")"); var x = d3.scaleTime() .range([0, width]); var xAxis = d3.axisBottom(x); var xAxisG = g.append("g") .attr("transform", "translate(0, " + height + ")"); d3.timer(function() { var now = Date.now(); x.domain([now - 5000, now]); xAxisG.call(xAxis); }); d3.select("button").on("click", function() { var time = Date.now(); var circle = g.append("circle") .attr("r", 80) .attr("stroke-opacity", 0) .attr("cy", Math.random() * height); circle.transition("time") .duration(5000) .ease(d3.easeLinear) .attrTween("cx", function(d) { return function(t) { return x(time); }; }) circle.transition() .duration(750) .ease(d3.easeCubicOut) .attr("r", 3.5) .attr("stroke-opacity", 1) .transition() .delay(5000 - 750 * 2) .ease(d3.easeCubicIn) .attr("r", 80) .attr("stroke-opacity", 0) .remove(); }); </script> LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed.