Skip to content

Instantly share code, notes, and snippets.

@mbostock mbostock/index.js
Created Aug 29, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.