Skip to content

Instantly share code, notes, and snippets.

@gamecubate
Last active August 29, 2015 13:57
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 gamecubate/9560766 to your computer and use it in GitHub Desktop.
Save gamecubate/9560766 to your computer and use it in GitHub Desktop.
Radio buttons test
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 960px;
height: 500px;
position: relative;
}
form {
position: absolute;
top: 1em;
left: 1em;
}
</style>
<body>
<form>
<input type="radio" name="city" id="city-montreal" checked>
<label for="ref-annulus">Montréal</label><br>
<input type="radio" name="city" id="city-quebec">
<label for="ref-planet">Québec</label><br>
<input type="radio" name="city" id="city-saguenay">
<label for="ref-sun">Saguenay</label>
</form>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 500,
radius = 80,
x = Math.sin(2 * Math.PI / 3),
y = Math.cos(2 * Math.PI / 3);
var offset = 0,
speed = 4,
start = Date.now();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")scale(.55)")
.append("g");
d3.selectAll("input[name=city]")
.on("change", function() {
console.log('change');
});
/*
d3.timer(function() {
var angle = (Date.now() - start) * speed,
transform = function(d) { return "rotate(" + angle / d.radius + ")"; };
frame.selectAll("path").attr("transform", transform);
frame.attr("transform", transform); // frame of reference
});
*/
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment