Skip to main content
100%

Gist 65b32812a88403c5b2c49fc2de450136

✓ Published0🌍 Public
Aadamjanes
Last edited Mar 17, 2018
Created on Mar 17, 2018

This example shows how to map two quantitative data fields—GPA and height—to screen positions using linear scales. The code defines an x-scale that translates GPA values into a horizontal range of 0 to 800 pixels, and a y-scale that maps height values to a vertical range of 500 to 0 pixels (reversed for typical Cartesian orientation). Both scales compute their domains dynamically from the data, expanding the minimum and maximum by 5% to add padding. The implementation uses D3.js’s `d3.scaleLinear` with explicit `.domain()` and `.range()` calls, relying on `d3.min` and `d3.max` to derive the input extents from the `data0` array.

AI-generated description

Similar vizzes