# classybrew

> Create class breaks and apply colorbrewer palette to output.

Latest version **0.0.3** (published 2016-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install classybrew
pnpm add classybrew
yarn add classybrew
bun add classybrew
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2016-09-29 |
| First published | 2016-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 38 |
| Author | Joshua Tanner |
| Maintainers | tannerjt |
| Keywords | colorbrewer, color theory, mapping |

## Links

- npm: https://www.npmjs.com/package/classybrew
- Repository: https://github.com/tannerjt/classybrew
- Homepage: https://github.com/tannerjt/classybrew#readme
- Issues: https://github.com/tannerjt/classybrew/issues
- npm.io page: https://npm.io/package/classybrew

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2016-09-29
- 0.0.2 — 2016-09-27

## README

##classybrew

**classybrew** lets you choose from several statistical algorithms (Jenks Natural Breaks, Quantile, Equal Interval) to generate class breaks based on your data.  **classybrew** has [colorbrewer](https://github.com/axismaps/colorbrewer) color palettes built in to quickly generate choropleth maps, graphics, tables, etc. with ease.

[View classybrew in action!](http://tannerjt.github.io/classybrew-www/examples/basic/)

Created By: [tannergeo](http://tannergeo.com)

###Using classybrew

**Basics - Setup**

```javascript
var brew = new classyBrew();
brew.setSeries([30.01, 14.9, 22.71, 24.96, 7.17, ...]);
brew.setNumClasses(5);
brew.setColorCode("BuGn");
```

**Basics - Classify**

```javascript
brew.classify('jenks'); // returns [7.17,14.9,19.3,22.71,26.9,31.26]
```

**Basics - Retrieval**

```javascript
var breaks = brew.getBreaks(); // returns [7.17,14.9,19.3,22.71,26.9,31.26]
var colors = brew.getColors(); // returns [rgb(237,248,251),rgb(178,226,226),rgb(102,194,164),rgb(44,162,95),rgb(0,109,44)]
brew.getColorInRange(7.5); // returns rgb(237,248,251)
```

**All classybrew Methods**

```javascript
//constructor
var brew = new classyBrew();

//_____setters______//
//__________________//

// classification
brew.setSeries(Array); // define array of data to classify
brew.setNumClasses(Number); // number of classes or breaks
//@Methods: equal_interval, quantile, jenks
brew.classify(Method:optional, Classes:optional); // returns classified data. Defaults to natural breaks methods

// color theory
brew.setColorCode(ColorCodeString); // color ramp code... see below

//_____getters______//
//__________________//

// classification
brew.getSeries(); // returns Array of original data
brew.getNumClasses(); // returns set number of classes
brew.getBreaks(); // will call classify but for performance returns pointer if classify has already been called
brew.getClassificationMethods(); // returns available classification methods to pass to classify()

//color theory
brew.getColorCodes(); // returns array of all available color codes
brew.getColorCodesByType(); // returns object of color codes by type (diverging, sequential, qualitative)
brew.getColorCode(); // returns set color code
brew.getColors(); // returns array of colors specific to your data
brew.getColorInRange(Num); // returns appropriate color for given number
```

***Color Theory***

The colors generated using classybrew are based on [Cynthia Brewer's](http://colorbrewer2.org/) sequential color ramps.  Below are the possible codes you can use when generating your color ramp with your data.  *BuGn -> Blue to Green*

```javascript
var brew = new classyBrew();
brew.getColorCodes();  // returns
/*
["OrRd", "PuBu", "BuPu", "Oranges", 
"BuGn", "YlOrBr", "YlGn", "Reds", 
"RdPu", "Greens", "YlGnBu", "Purples", 
"GnBu", "Greys", "YlOrRd", "PuRd", "Blues", 
"PuBuGn", "Spectral", "RdYlGn", "RdBu", 
"PiYG", "PRGn", "RdYlBu", "BrBG", 
"RdGy", "PuOr", "Set2", "Accent", 
"Set1", "Set3", "Dark2", "Paired", 
"Pastel2", "Pastel1"];
*/
```

You can also view the simple test file (./test/index.html) to better understand how to use the library and visualize the color palettes.

This tool was built with inspiration from two outstanding open source repositories.

+ [axismaps/colorbrewer](https://github.com/axismaps/colorbrewer) - Cynthia Brewers Color Theory
+ [simogeo/geostats](https://github.com/simogeo/geostats)

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