-
-
Save mbostock/1d96d9fdecf1b214f1395f94e0ba8758 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
#update { | |
position: absolute; | |
top: 10px; | |
left: 10px; | |
} | |
</style> | |
<button id="update">Update</button> | |
<svg width="960" height="500"> | |
<g transform="translate(0,150)" id="axis"></g> | |
</svg> | |
<script src="https://d3js.org/d3.v4.0.0-alpha.44.min.js"></script> | |
<script> | |
var scale = d3.scaleLinear() | |
.rangeRound([100, 860]); | |
var axis = d3.axisBottom(scale); | |
d3.select("#update") | |
.on("click", clicked); | |
d3.select("#axis") | |
.call(update); | |
function clicked() { | |
d3.select("#axis") | |
.transition() | |
.call(update); | |
} | |
function update(group) { | |
scale.domain([0, Math.random() * 100]); | |
group.call(axis); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment