# geocolor

> style geojson based on data classifications

Latest version **0.0.16** (published 2014-05-09) · MIT license · 0 weekly downloads

## Install

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

## 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.16 |
| Published | 2014-05-09 |
| First published | 2014-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 114 |
| Author | morganherlocker |
| Maintainers | morganherlocker |
| Keywords | geojson, style |

## Links

- npm: https://www.npmjs.com/package/geocolor
- Repository: https://github.com/morganherlocker/geocolor
- Issues: https://github.com/morganherlocker/geocolor/issues
- npm.io page: https://npm.io/package/geocolor

## Dependencies (4)

- [color](https://npm.io/package/color.md) ~0.5.0
- [lodash](https://npm.io/package/lodash.md) ~2.4.1
- [chroma-js](https://npm.io/package/chroma-js.md) ~0.5.6
- [simple-statistics](https://npm.io/package/simple-statistics.md) ~0.7.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.16 (latest) — 2014-05-09
- 0.0.17-0 (next) — 2019-04-09
- 0.0.15 — 2014-05-09
- 0.0.14 — 2014-05-08
- 0.0.13 — 2014-05-05
- 0.0.12 — 2014-03-19
- 0.0.11 — 2014-03-19
- 0.0.10 — 2014-03-19
- 0.0.9 — 2014-03-06
- 0.0.8 — 2014-03-06
- 0.0.7 — 2014-03-04
- 0.0.6 — 2014-03-04
- 0.0.5 — 2014-03-04
- 0.0.4 — 2014-02-07
- 0.0.3 — 2014-02-06
- … 2 more at https://npm.io/package/geocolor/versions

## README

Geocolor
========

[![Build Status](https://travis-ci.org/morganherlocker/geocolor.png?branch=master)](https://travis-ci.org/morganherlocker/geocolor)

Geocolor is both a javascript module and a web app. The web app makes it easy to demo the functionality or use to create quick visualizations without having to code. It can be found at [geocolor.io](http://geocolor.io/#).

Geocolor classifies data contained in geojson properties, and assigns color values based on the [simplestyle-spec](https://github.com/mapbox/simplestyle-spec/blob/master/1.1.0/README.md). This means that when your geojson is rendered in github, [gists](https://gist.github.com/morganherlocker/b963cc241018326f1d16), mapbox, or other simplestyle-spec compliant renderers, you will get nice styles that help to visualize your data.

![sc-counties](https://raw.github.com/morganherlocker/geocolor/master/img/Screen%20Shot%202014-03-04%20at%204.25.20%20PM.jpg)

##Install

```bash
npm install geocolor
```

##Colors

The color gradient is defined by simply passing an array of colors with as many stops as you want.

##Classification

Curently supported classifications:

- equal intervals
- quantiles
- jenks
- custom
- random
- all

##Example

![gradient](https://raw.github.com/morganherlocker/geocolor/master/img/Screen%20Shot%202014-02-06%20at%203.55.30%20PM.jpg)

```js
var geocolor = require('geocolor')

var cities = {
  // [point data](https://github.com/morganherlocker/geocolor/blob/master/test/in/cities.geojson)
}

var z = 'Population',
    numberOfBreaks = 5,
    colors = ['green', 'yellow', 'red']

// jenks
geoJenks = geocolor.jenks(cities, z, numberOfBreaks, colors)
console.log(geoJenks)

// quantiles
geoQuantiles = geocolor.quantiles(cities, z, numberOfBreaks, colors)
console.log(geoQuantiles)

// equal intervals
geoEqualIntervals = geocolor.equalIntervals(cities, z, numberOfBreaks, colors)
console.log(geoEqualIntervals)

// custom breaks
geoCustom = geocolor.custom(cities, z, [0,200000,300000,400000,500000,800000,1000000,1000000000], colors)
console.log(geoCustom)

// random colors
geoRandom = geocolor.random(geo, ['green', 'yellow', 'red', 'blue', 'purple', 'orange', 'pink'])
console.log(geoRandom)

// all (assigns the same style to all features)
var style = {
  'stroke': 'blue',
  'fill-opacity': .7,
  'fill': 'green'
}
geoAll = geocolor.all(geo, style)
console.log(geoRandom)
```

You can also pass in a custom style object to any of the functions that will applied to all features as an optional parameter. The following will perform a quantile white to red ramp, will set the stroke to blue, and will set the fill opacity to .4.

```js
var geocolor = require('geocolor')

var cities = {
  // [point data](https://github.com/morganherlocker/geocolor/blob/master/test/in/cities.geojson)
}

var z = 'Population',
    numberOfBreaks = 15,
    colors = ['white', 'red']

var style = {
  'stroke': 'blue',
  'fill-opacity': .4
}

// quantiles
geoQuantiles = geocolor.quantiles(cities, z, numberOfBreaks, colors, style)
console.log(geoQuantiles)
```

##Dev

Running tests:

```bash
npm test
```

##More Examples

![rivers](https://raw.github.com/morganherlocker/geocolor/master/img/Screen%20Shot%202014-03-04%20at%209.51.10%20PM.jpg)

![choloropleth](http://morganherlocker.com/img/poverty_styled.jpg)

![gradient](https://raw.github.com/morganherlocker/geocolor/master/img/Screen%20Shot%202014-02-06%20at%203.13.09%20PM.jpg)

![gradient](https://raw.github.com/morganherlocker/geocolor/master/img/Screen%20Shot%202014-02-06%20at%209.57.54%20AM.jpg)

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