npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

classybrew

v0.0.3

Published

Create class breaks and apply colorbrewer palette to output.

Downloads

3,079

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 color palettes built in to quickly generate choropleth maps, graphics, tables, etc. with ease.

View classybrew in action!

Created By: tannergeo

###Using classybrew

Basics - Setup

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

Basics - Classify

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

Basics - Retrieval

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

//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 sequential color ramps. Below are the possible codes you can use when generating your color ramp with your data. BuGn -> Blue to Green

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.