Skip to content

Instantly share code, notes, and snippets.

@mbostock
Created August 29, 2012 19:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mbostock/3517374 to your computer and use it in GitHub Desktop.
Lazy Scale Domain
// Create a scale, but don't set the domain until the data is known.
var x = d3.scale.linear()
.range([0, width]);
// Load the data.
d3.json("data.json", function(data) {
// Now we can compute the domain and update the scale.
x.domain([0, d3.max(data)]);
// And here's where we'd visualize the data…
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment