Socket
Socket
Sign inDemoInstall

@vx/scale

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/scale

vx scale


Version published
Weekly downloads
129K
decreased by-24.47%
Maintainers
3
Weekly downloads
 
Created

What is @vx/scale?

@vx/scale is a part of the vx (now known as visx) collection of visualization components for React. It provides a set of utilities for creating scales, which are functions that map from an input domain to an output range. These scales are essential for creating visualizations as they help in mapping data values to visual properties like position, color, and size.

What are @vx/scale's main functionalities?

Linear Scale

Linear scales map a continuous input domain to a continuous output range. This is useful for creating visualizations where you need a direct proportional mapping, such as bar charts or scatter plots.

const scaleLinear = require('@vx/scale').scaleLinear;
const linear = scaleLinear({
  domain: [0, 100],
  range: [0, 500]
});
console.log(linear(50)); // 250

Band Scale

Band scales are useful for creating visualizations with discrete bands, such as bar charts with categorical data. They map a discrete domain to a continuous range with optional padding between bands.

const scaleBand = require('@vx/scale').scaleBand;
const band = scaleBand({
  domain: ['A', 'B', 'C'],
  range: [0, 300],
  padding: 0.1
});
console.log(band('B')); // 110

Ordinal Scale

Ordinal scales map a discrete domain to a discrete range. This is useful for mapping categories to colors or other visual properties.

const scaleOrdinal = require('@vx/scale').scaleOrdinal;
const ordinal = scaleOrdinal({
  domain: ['apple', 'banana', 'cherry'],
  range: ['red', 'yellow', 'purple']
});
console.log(ordinal('banana')); // 'yellow'

Time Scale

Time scales are used for mapping dates and times to a continuous range. This is particularly useful for time series data.

const scaleTime = require('@vx/scale').scaleTime;
const time = scaleTime({
  domain: [new Date(2020, 0, 1), new Date(2020, 11, 31)],
  range: [0, 100]
});
console.log(time(new Date(2020, 5, 1))); // 50

Other packages similar to @vx/scale

Keywords

FAQs

Package last updated on 14 Feb 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc