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.
npm install geocolor
The color gradient is defined by simply passing an array of colors with as many stops as you want.
Curently supported classifications:
var geocolor =var cities =// [point data]()var z = 'Population'numberOfBreaks = 5colors = '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]()var z = 'Population'numberOfBreaks = 15colors = 'white' 'red'var style ='stroke': 'blue''fill-opacity': 4// quantilesgeoQuantiles = geocolorconsole