UNPKG

2.21 kBMarkdownView Raw
1<h1 align="center">
2<b>@antv/scale</b>
3</h1>
4
5<div align="center">
6
7> 将抽象数据映射为视觉数据的比例尺工具包。 [在线演示](https://observablehq.com/@pearmini/antv-scale) · [English](./README.en-US.md)
8
9![scale mapping](https://user-images.githubusercontent.com/7856674/116353528-85644a80-a829-11eb-85e4-3463a29000a9.png)
10
11[![Build Status](https://github.com/antvis/scale/workflows/build/badge.svg?branch=master)](https://github.com/antvis/scale/actions)
12[![Coverage Status](https://img.shields.io/coveralls/github/antvis/scale/master.svg)](https://coveralls.io/github/antvis/scale?branch=master)
13[![npm Version](https://img.shields.io/npm/v/@antv/scale.svg)](https://www.npmjs.com/package/@antv/scale)
14[![npm Download](https://img.shields.io/npm/dm/@antv/scale.svg)](https://www.npmjs.com/package/@antv/scale)
15[![npm License](https://img.shields.io/npm/l/@antv/scale.svg)](https://www.npmjs.com/package/@antv/scale)
16
17</div>
18
19## ✨ 特性
20
21- **功能强大**:内置包含 15+ 丰富的比例尺类型,满足各种不同的定制化需求。
22- **高性能**:利用各种手段方法去提升数据映射的性能。
23- **TypeScript**:全部 TypeScript,并提供了完整有效的类型定义。
24
25![scale examples](https://gw.alipayobjects.com/mdn/rms_40052e/afts/img/A*Usg2S685JQkAAAAAAAAAAAAAARQnAQ)
26
27## 📦 安装
28
29```bash
30$ npm install @antv/scale
31```
32
33## 🔨 上手
34
35- 基本用法
36
37```ts
38import { Linear, LinearOptions } from '@antv/scale';
39
40const options: LinearOptions = {
41 domain: [0, 10],
42 range: [0, 100],
43};
44const x = new Linear(options);
45
46x.map(2); // 20
47x.invert(20); // 2
48x.getTicks(); // [0, 2.5, 5, 7.5, 10]
49```
50
51- 自定义可读 tickMethod
52
53```ts
54import { Linear } from '@antv/scale';
55
56const x = new Linear({
57 domain: [0, 10],
58 range: [0, 100],
59 tickCount: 3,
60 tickMethod: () => [0, 5, 10],
61});
62
63x.getTicks(); // [0, 5, 10]
64```
65
66## 📎 链接
67
68- [入门介绍](https://observablehq.com/@pearmini/antv-scale)
69- [API 索引](./docs/api/readme.md)
70
71## 📮 贡献
72
73```bash
74$ git clone git@github.com:antvis/scale.git
75
76$ cd scale
77
78$ npm i
79
80$ npm t
81```
82
83写完代码之后,提交 PR 即可。
84
85## 📄 License
86
87MIT@[AntV](https://github.com/antvis).