Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

asciiplot

joeledwards147PUBLIC_DOMAIN1.0.0

Nice-looking lightweight console ASCII line charts ╭┈╯ with no dependencies (clone of asciichart)

asciiplot, ascii, chart, charting, charts, console, terminal, draw, box-drawing, box drawing, drawing, stats, line, linear, plot, graph, ascii graphics, graphics, command line, commandline, bash, shell, sh, light

readme

asciiplot

Console ASCII line charts in pure Javascript (for NodeJS) with no dependencies (clone of asciichart). This code is absolutely free for any usage, you just do whatever you want.

Console ASCII Line charts in pure Javascript (for NodeJS)

Usage

NodeJS

npm install asciiplot
var asciiplot = require ('asciiplot')
var s0 = new Array (120)
for (var i = 0; i < s0.length; i++)
    s0[i] = 15 * Math.sin (i * ((Math.PI * 4) / s0.length))
console.log (asciiplot.plot (s0))

Options

The width of the chart will always equal the length of data series. The height and range are determined automatically.

var s0 = new Array (120)
for (var i = 0; i < s0.length; i++)
    s0[i] = 15 * Math.sin (i * ((Math.PI * 4) / s0.length))
console.log (asciiplot.plot (s0))
Console ASCII Line charts in pure Javascript (for NodeJS)

The output can be configured by passing a second parameter to the plot (series, config) function. The following options are supported:

var config = {

    offset:  3,          // axis offset from the left (min 2)
    padding: '       ',  // padding string for label formatting (can be overrided)
    height:  10,         // any height you want

    // the label format function applies default padding
    format:  function (x, i) { return (padding + x.toFixed (2)).slice (-padding.length) }
}

Scale To Desired Height

Console ASCII Line charts in pure Javascript (for NodeJS)
var s = []
for (var i = 0; i < 120; i++)
    s[i] = 15 * Math.cos (i * ((Math.PI * 8) / 120)) // values range from -15 to +15
console.log (asciiplot.plot (s, { height: 6 }))     // this rescales the graph to ±3 lines
Console ASCII Line charts in pure Javascript (for NodeJS)

Auto-range

var s2 = new Array (120)
s2[0] = Math.round (Math.random () * 15)
for (i = 1; i < s2.length; i++)
    s2[i] = s2[i - 1] + Math.round (Math.random () * (Math.random () > 0.5 ? 2 : -2))
console.log (asciiplot.plot (s2))
Console ASCII Line charts in pure Javascript (for NodeJS)