![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@types/d3-scale
Advanced tools
Package description
The @types/d3-scale package provides TypeScript type definitions for the d3-scale library, which is part of D3.js, a JavaScript library for producing dynamic, interactive data visualizations in web browsers. This package helps developers by enabling type checking and IntelliSense support in TypeScript projects using d3-scale.
Creating Linear Scales
Linear scales are a type of quantitative scale that create a linear mapping from an input domain to an output range. This is useful for scaling a dataset for graphical representation.
import { scaleLinear } from 'd3-scale';
const linearScale = scaleLinear().domain([0, 100]).range([0, 1]);
console.log(linearScale(50)); // Output: 0.5
Creating Ordinal Scales
Ordinal scales map a set of named categories to an output range. This is particularly useful for assigning colors or other styles based on categorical data.
import { scaleOrdinal } from 'd3-scale';
const colorScale = scaleOrdinal().domain(['apple', 'banana', 'cherry']).range(['red', 'yellow', 'purple']);
console.log(colorScale('banana')); // Output: yellow
Creating Time Scales
Time scales are used for time-based data, mapping dates (Date objects) from an input domain to a numeric range. This is useful for creating time-based charts like timelines or Gantt charts.
import { scaleTime } from 'd3-scale';
const timeScale = scaleTime().domain([new Date(2020, 0, 1), new Date(2020, 11, 31)]).range([0, 100]);
console.log(timeScale(new Date(2020, 6, 1))); // Output: 50
Provides TypeScript definitions for d3-array, similar to @types/d3-scale but focused on array manipulation functions. While d3-scale deals with data scaling and mapping, d3-array provides methods for aggregating, sorting, and manipulating arrays.
Offers TypeScript definitions for d3-axis, which is used to create axes for charts in D3. This package complements @types/d3-scale by providing types for components that utilize scales to display axes and grid lines in visualizations.
Readme
npm install --save @types/d3-scale
This package contains type definitions for d3-scale (https://github.com/d3/d3-scale/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/d3-scale.
These definitions were written by Tom Wanzek, Alex Ford, Boris Yankov, denisname, rulonder, and Nathan Bierema.
FAQs
TypeScript definitions for d3-scale
We found that @types/d3-scale demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.