Skip to main content
100%

Lazy Scale Domain

✓ Published0🌍 Public
Mmbostock
Last edited Aug 29, 2012
Created on Aug 29, 2012

This example demonstrates how to defer a scale’s domain definition until after data loading, highlighting the flexibility of D3’s linear scale. Using `d3.scale.linear()`, it initializes a scale with only a range, then after fetching data via `d3.json`, it computes the maximum value with `d3.max(data)` and assigns the domain. This modular pattern separates scale creation from data-dependent configuration, enabling reusable code where the data source remains dynamic. The visualization itself is not drawn here—the code stops at updating the scale, showing the setup phase for later rendering.

AI-generated description

Similar vizzes