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

generate-histogram

v1.0.2

Published

Pass in a json file with histogram data and this will generate an ascii-histogram

Downloads

1

Readme

node-generate-histogram

Pass in a csv file with histogram data and this will generate an ascii-histogram

Version

1.0.2

Installation

$ npm install generate-histogram

Usage

There are two functions,

  • Generate a basic histogram
  • Calculate lag (time difference) between two time columns and show a chart of that lag

You need to set the following environment variables:

DATA_FILE - Path to the csv file containing the data

CHART_TYPE - Either "simple" for a basic histogram or "lag" for a lag chart.

$ export DATA_FILE="PATH_TO_YOUR_FILE"
$ export CHART_TYPE="simple"
$ npm start

Generating a simple chart

Create a csv file with two columns; the variable and the frequency.

bananas,6
apples,1
oranges,24
figs,4

Then run as follows:

$ export DATA_FILE='basicSample.csv'; export CHART_TYPE='simple'; npm start

  bananas | ###############                                              | 6
   apples | ###                                                          | 1
  oranges | ############################################################ | 24
     figs | ##########                                                   | 4

Generating a lag chart

Create a csv file with two columns; the start time and end time (it needs to be in YYYY-mm-dd HH:MM:SS format):

2016-01-01 17:57:20,2016-01-01 17:57:32
2016-01-01 17:57:21,2016-01-01 17:57:32
2016-01-01 17:57:21,2016-01-01 17:57:37
2016-01-01 17:57:22,2016-01-01 17:57:37
2016-01-01 17:57:23,2016-01-01 17:57:37
2016-01-01 17:57:24,2016-01-01 17:57:37
2016-01-01 17:57:25,2016-01-01 17:57:37
2016-01-01 17:57:26,2016-01-01 17:57:37
2016-01-01 17:57:26,2016-01-01 17:57:40

Then run as follows:

$ export DATA_FILE='lagSample.csv'; export CHART_TYPE='lag'; npm start

  2016-01-01 17:57:20 | #############################################                | 12
  2016-01-01 17:57:21 | ############################################################ | 16
  2016-01-01 17:57:22 | ########################################################     | 15
  2016-01-01 17:57:23 | #####################################################        | 14
  2016-01-01 17:57:24 | #################################################            | 13
  2016-01-01 17:57:25 | #############################################                | 12
  2016-01-01 17:57:26 | #####################################################        | 14

Examples

See examples/basicHistogram.sh and examples/lagHistogram.sh to get started. You can run it with the following.

user@machine:~/useful/node-generate-histogram (master u=)$ cd examples/
user@machine:~/useful/node-generate-histogram/examples (master u=)$ sh basicHistogram.sh
  17:00:00 | ###                                                          | 15
  17:00:01 | #                                                            | 5
  17:00:02 | #################                                            | 83
  17:00:03 | ############################################################ | 288
  17:00:04 | #####                                                        | 23
  17:00:06 | ####################                                         | 96
  17:00:07 | ###                                                          | 14
  17:00:08 | ###                                                          | 14
  17:00:09 | ######                                                       | 29

user@machine:~/useful/node-generate-histogram/examples (master u=)$