# @antv/scale

> Toolkit for mapping abstract data into visual representation.

Latest version **0.5.2** (published 2025-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @antv/scale
pnpm add @antv/scale
yarn add @antv/scale
bun add @antv/scale
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.2 |
| Published | 2025-09-04 |
| First published | 2018-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 528.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | AntV |
| Maintainers | lvisei, freestyle21, soundquiet, elaine.q.10, sturuby, sakuya223, serializedowen, xdzhao, yangzhanmei, wjgogogo, leungwensen, dori, iaaron, yard, simaq, dxq613, intchous, susan_ann, jinke.li, lzxue, army8735, atool, baizn, dengfuping, neoddish, jeffy2012, zqlu, afc163, pomelo-nwu, kopiluwaky, ccnuzindex, panyuqi, bubkoo, zengyue, kasmine, boyu.zlj, l1ud0ngq1, newbyvector, winniexing, chenluli, kn9117, xdddst, semious2020, esora, nadia_liu, bbsqq, mxz96102, openwayne, pearmini, pddpd, yiqianyao, zhanba, cxxxxxn, laixingui.lxg, susiwen8, yanxiong, zeyuwang, rainy25ghz, zhangjunjie-loki, flash1, yisi.wang, dreammy23, biupiubiupiu, basketduck, xuying1027, banxuan, bqxbqxbqx, duxinyue023, wang1212, leondt1, xcf(-_-), boyyangzai, siqishen, interstellarmt, moayuisuda |
| Keywords | antv, visualization, mapping |

## Links

- npm: https://www.npmjs.com/package/@antv/scale
- Repository: https://github.com/antvis/scale
- Homepage: https://github.com/antvis/scale#readme
- Issues: https://github.com/antvis/scale/issues
- npm.io page: https://npm.io/package/@antv/scale

## Dependencies (3)

- [fecha](https://npm.io/package/fecha.md) ^4.2.1
- [@antv/util](https://npm.io/package/@antv/util.md) ^3.3.7
- [color-string](https://npm.io/package/color-string.md) ^1.5.5

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.5.2 (latest) — 2025-09-04
- 0.4.0-beta.1 (beta) — 2021-04-26
- 0.1.5 (v1.0-latest) — 2020-03-12
- 0.5.1 — 2025-08-28
- 0.5.0 — 2025-08-19
- 0.4.16 — 2024-05-13
- 0.4.15 — 2023-12-20
- 0.4.14 — 2023-12-18
- 0.4.13 — 2023-11-24
- 0.4.12 — 2023-04-21
- 0.4.11 — 2022-09-22
- 0.4.10 — 2022-09-19
- 0.3.18 — 2022-05-17
- 0.4.9 — 2022-05-12
- 0.4.8 — 2022-04-27
- … 59 more at https://npm.io/package/@antv/scale/versions

## README

<h1 align="center">
<b>@antv/scale</b>
</h1>

<div align="center">

> Toolkit for mapping abstract data into visual representation. [Living Demo](https://observablehq.com/@pearmini/antv-scale) · [中文文档](./README.md)

![scale mapping](https://user-images.githubusercontent.com/7856674/116353528-85644a80-a829-11eb-85e4-3463a29000a9.png)

[![Build Status](https://github.com/antvis/scale/workflows/build/badge.svg?branch=master)](https://github.com/antvis/scale/actions)
[![Coverage Status](https://img.shields.io/coveralls/github/antvis/scale/master.svg)](https://coveralls.io/github/antvis/scale?branch=master)
[![npm Version](https://img.shields.io/npm/v/@antv/scale.svg)](https://www.npmjs.com/package/@antv/scale)
[![npm Download](https://img.shields.io/npm/dm/@antv/scale.svg)](https://www.npmjs.com/package/@antv/scale)
[![npm License](https://img.shields.io/npm/l/@antv/scale.svg)](https://www.npmjs.com/package/@antv/scale)

</div>

## ✨ Features

- **Powerful**: Ability to customize tickMethod are offered with abundant kinds of scales.
- **High performance**: Use different methods to cache some state of scales to improve performance.
- **Fully embrace TypeScript**: All code are written in TypeScript and complete type definition files are provided.

![scale examples](https://gw.alipayobjects.com/mdn/rms_40052e/afts/img/A*Usg2S685JQkAAAAAAAAAAAAAARQnAQ)

## 📦 Installation

```bash
$ npm install @antv/scale
```

## 🔨 Getting Started

- Basic usage

```ts
import { Linear, LinearOptions } from '@antv/scale';

const options: LinearOptions = {
  domain: [0, 10],
  range: [0, 100],
};
const x = new Linear(options);

x.map(2); // 20
x.invert(20); // 2
x.getTicks(); // [0, 2.5, 5, 7.5, 10]
```

- Customize tickMethod

```ts
import { Linear } from '@antv/scale';

const x = new Linear({
  domain: [0, 10],
  range: [0, 100],
  tickCount: 3,
  tickMethod: () => [0, 5, 10],
});

x.getTicks(); // [0, 5, 10]
```

## 📎 Links

- [Introduction](https://observablehq.com/@pearmini/antv-scale)
- [API Reference](./docs/api/readme.md)

## 📮 Contribution

```bash
$ git clone git@github.com:antvis/scale.git

$ cd scale

$ npm i

$ npm t
```

Then send a pull request after coding.

## 📄 License

MIT@[AntV](https://github.com/antvis).

---
_Source: https://npm.io/package/@antv/scale · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
