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

ascii-graphs

v1.0.2

Published

Ascii histogram visualizations for node.js

Downloads

1

Readme

Ascii Graphs js

A simple ascii graphing tool in node.js (and possibly in the browser)

Currently only supporting Histogram (Barcharts) and Sparkline

Basic Usage

var data = [1, 2, 3, 4, 5];
var formatted = histogram_format(data);
console.log(formatted.join('\n'));

API

var formatted_string = histogram_format(data, theme, options);
var options = {
    chart_width /* width of a full bar */
    divider /* character to mark the start and end of bar
    block_formatter /* callback for generating a character block */
    last_formatter /* callback for the last character, can handle partial values */
    max /* override max value */
    min /* override min value */
}

clear_and_log(lines) - clears previously printed lines and updates with new formatted lines

### Examples

- node test.js
- node system.js
- browser test.html


```sh
echo "Array(20).fill(0).map(_=>Math.random() * 1000 | 0).forEach(x => console.log(x))"  | node - | node stdin

echo "Array(2000).fill(0).map(_=>Math.random() * 10000 | 0).forEach(x => console.log(x))"  | node - | node stdin-histogram

### Themes

Use one of these: `standard`, `jim`,`equals`,`stars`,`pipes`,`sparks`, `bitly`.

eg.

var formatted = histogram_format(data, 'jim'); var formatted = histogram_format(data, 'pipes');


### Customization

Take a look at `test.js`

node test

default options

  0 |     | 0.00%
  1 |▉    | 6.67%
  2 |█▋   | 13.33%
  3 |██▌  | 20.00%
  4 |███▎ | 26.67%
  5 |████ | 33.33%

thin (width = 1)

  0 |  | 0.00%
  1 |▎ | 6.67%
  2 |▌ | 13.33%
  3 |▋ | 20.00%
  4 |▉ | 26.67%
  5 |█ | 33.33%

longer (width = 14)

  0 |               | 0.00%
  1 |██▉            | 6.67%
  2 |█████▋         | 13.33%
  3 |████████▌      | 20.00%
  4 |███████████▎   | 26.67%
  5 |██████████████ | 33.33%

random data + standard theme

844 |███▉ | 24.55%
357 |█▋   | 10.38%
448 |██   | 13.03%
899 |████ | 26.13%
473 |██▏  | 13.74%
418 |█▉   | 12.17%

jim theme

844 --------------------------------------------------------o     24.55%
357 -----------------------o                                      10.38%
448 -----------------------------o                                13.03%
899 ------------------------------------------------------------o 26.13%
473 -------------------------------o                              13.74%
418 ---------------------------o                                  12.17%

equals theme

844 |============================]  | 24.55%
357 |===========]                   | 10.38%
448 |==============]                | 13.03%
899 |==============================]| 26.13%
473 |===============]               | 13.74%
418 |=============]                 | 12.17%

stars theme

844 |******************   | 24.55%
357 |*******              | 10.38%
448 |*********            | 13.03%
899 |******************** | 26.13%
473 |**********           | 13.74%
418 |*********            | 12.17%

pipes theme

844 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||    | 24.55%
357 |||||||||||||||||||||||||                                     | 10.38%
448 |||||||||||||||||||||||||||||||                               | 13.03%
899 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | 26.13%
473 |||||||||||||||||||||||||||||||||                             | 13.74%
418 |||||||||||||||||||||||||||||                                 | 12.17%

sparks theme

844 |█ | 24.55%
357 |▄ | 10.38%
448 |▅ | 13.03%
899 |█ | 26.13%
473 |▅ | 13.74%
418 |▅ | 12.17%

bitly theme

204 |∎∎∎∎∎∎∎∎∎∎∎∎∎∎                                               | 9.60%
597 |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎                   | 28.10%
164 |∎∎∎∎∎∎∎∎∎∎∎                                                  | 7.74%
 82 |∎∎∎∎∎                                                        | 3.85%
234 |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎                                             | 11.01%
844 |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ | 39.71%

loop

1330 |██████████████████████████████ | 22.96% 721 |████████████████▍ | 12.44% 827 |██████████████████▊ | 14.29% 1250 |████████████████████████████▎ | 21.59% 844 |███████████████████▏ | 14.57% 820 |██████████████████▌ | 14.15%

sparkline

| ▁▃▄▅▆▇█| Min: 1.00 Avg: 3.50 Max: 8.00

longer sparkline

|▃▃▁▅▄ ▆█▅▆▅▇▆▄▄▆▇▅▁▇▅▃▆▃▄▃▅▃▄▄▅▅▄▄▅▃▁▄▄▅▁▅▇▆| Min: 0.30 Avg: 49.80 Max: 99.42

animate sparkline

|▃▁▁▁▃▄▄▅▆▆▇▇▇█▇▇▇▇▆▆▅▄▄▃▁▁ ▁▃▃▄▅▅▆▆| Min: -1.00 Avg: 0.84 Max: 1.00

node system Memory usage 16428531712 |████████████████████████████▊ | 100.00% CPU Usage

  0 |████████▊            | 27.44%
  0 |█▍                   | 4.22%
  0 |███████▋             | 24.02%
  0 |█▍                   | 4.22%
  0 |█████▍               | 16.89%
  0 |▊                    | 2.11%
  0 |██████▏              | 19.00%
  0 |▊                    | 2.11%

Trend lines |▅▄▄▄▄▄▄▅▄▄▄▄▄▃▃▃▃▃▃▃▃▄▄▃▄▃▃▄▄▃▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.22 Max: 1.00 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.02 Max: 1.00 |▄▄▃▃▄▃▄▄▄▃▃▄▄▃▃▃▃▃▃▃▃▃▃▃▄▃▁▄▃▃▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.19 Max: 1.00 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.02 Max: 1.00 |▃▃▄▃▃▃▃▄▃▃▃▄▃▃▃▃▁▃▁▁▃▃▃▃▃▁▃▃▃▃▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.16 Max: 1.00 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.02 Max: 1.00 |▄▃▃▃▃▃▃▃▃▃▃▃▃▃▁▁▁▁▃▁▃▁▃▁▃▁▁▃▃▁▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.13 Max: 1.00 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| Min: 0.00 Avg: 0.02 Max: 1.00


#### Other projects that makes ascii graphs

- https://github.com/mkaz/termgraph
- https://github.com/Evizero/UnicodePlots.jl
- https://github.com/kroitor/asciichart
- https://github.com/bitly/data_hacks