@antv/scale

Toolkit for mapping abstract data into visual representation.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
30Mar 24, 2021Mar 24, 2021Minified + gzip package size for @antv/scale in KB

Readme

@antv/scale

Toolkit for mapping abstract data into visual representation.

scale mapping

Build Status Coverage Status npm Version npm Download npm License

✨ 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

📦 Installation

$ npm install @antv/scale

🔨 Getting Started

  • Basic usage
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
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

📮 Contribution

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

$ cd scale

$ npm i

$ npm t

Then send a pull request after coding.

📄 License

MIT@AntV.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.