geobuckets
v0.0.3
Published
Lightweight Javascript (TypeScript, really) library for classification. Dependency free, tested, and type safe.
Downloads
802
Maintainers
Readme
🌎🪣 GeoBuckets
Lightweight Javascript (TypeScript, really) library for classification. Dependency free, tested, and type safe.
Features
- :fire: supports 6 classification types
- ⚖️: Small!
- :rocket: 4.4kb minifed, 1.7kb gzipped
- 0️⃣ zero dependencies
- 🌲 tree-shakeable
- :test_tube: fully tested
- :label: fully typed
- :rock: asynchronous and non-blocking
Supports
- Equal Intervals (EQI)
equalIntervalBuckets
- Standard Deviation (STD)
standardDeviationBuckets
- Arithmetic Progression (APG)
arithmeticProgressionBuckets
- Geometric Progression (GPG)
geometricProgressionBuckets
- Quantiles (QNT)
quantileBuckets
- Jenks (JNK)
jenksBuckets
Install
Install through NPM
npm install geobuckets
Usage
All outward facing functions are async and must be called with await XXX
Explicit import:
import { jenksBuckets } from "geobuckets";
const data: Array<number> = [60, 26, 20, 17, 10, 27, 98, 42, 55, 35];
const numClasses: number = 3;
const buckets: Array<number> = await jenksBuckets(data, numClasses);
console.log(buckets) >> [10, 35, 60, 98];
Helper function and type
import { generateBuckets, BucketTypes } from "geobuckets";
const data: Array<number> = [60, 26, 20, 17, 10, 27, 98, 42, 55, 35];
const numClasses: number = 3;
const buckets: Array<number> = await generateBuckets(
BucketTypes.JNK,
data,
numClasses
);
console.log(buckets) >> [10, 35, 60, 98];
A modern implementation of the GeoStats library by Simon Georget (MIT license)