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.
Geocolor classifies data contained in geojson properties, and assigns color values based on the simplestyle-spec. This means that when your geojson is rendered in github, gists, mapbox, or other simplestyle-spec compliant renderers, you will get nice styles that help to visualize your data.
Install
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
var 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' // jenksgeoJenks = geocolorconsole // quantilesgeoQuantiles = geocolorconsole // equal intervalsgeoEqualIntervals = geocolorconsole // custom breaksgeoCustom = geocolorconsole // random colorsgeoRandom = geocolorconsole // all (assigns the same style to all features)var style = 'stroke': 'blue' 'fill-opacity': 7 'fill': 'green'geoAll = geocolorallgeo styleconsole
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.
var 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 // quantilesgeoQuantiles = geocolorconsole
Dev
Running tests:
npm test