d3-scale
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
d3-array | 3.2.4 | 37.48 kB | ISC | prod | |
d3-format | 3.1.0 | 14.48 kB | ISC | prod | |
d3-interpolate | 3.0.1 | 17.62 kB | ISC | prod | |
d3-time-format | 4.1.0 | 20.89 kB | ISC | prod | |
d3-time | 3.1.0 | 13.23 kB | ISC | prod |
D3-scale is an npm package that maps abstract data to visual representation through scales. The scales offer a convenient workflow when mapping a dimension of abstract data to a visual representation. It encompasses a variety of visual encodings such as position, colors, widths, and symbol size, and is compatible with all types of data, such as categorical, discrete, and named. This makes d3-scale a valuable tool in the construction of data visualization projects, like scatterplots, bar charts, or heat maps.
Using d3-scale comes with this simple installation via npm: npm install d3-scale
. It can then be imported into a project through its module syntax: import {scaleLinear} from "https://cdn.skypack.dev/d3-scale@4"
. A usage example would be:
<script type="module">
import {scaleLinear} from "https://cdn.skypack.dev/d3-scale@4";
const x = scaleLinear();
</script>
Once imported, a scale can then be created and utilized flexibly based on your specific project needs. For instance, a linear scale could be created like so:
var x = d3.scaleLinear()
.domain([10, 130])
.range([0, 960]);
x(20); // Returns 80
x(50); // Returns 320
Here, the domain has been set to go from 10 to 130, while the range runs from 0 to 960.
The documentation for d3-scale is primarily housed in its GitHub repository (https://github.com/d3/d3-scale). The readme provides a thorough overview of the package, along with detailed API references and usage examples for each type of scale (continuous, ordinal, quantize, etc.). There are also links to relevant tutorials and additional resources for further understanding and utilization of the d3-scale tool.