Coder Social home page Coder Social logo

sparkly's Introduction

sparkly

Generate sparklines ▁▂▃▅▂▇

JavaScript port of spark.sh.

Some cool use-cases.

Install

npm install sparkly

Usage

import sparkly from 'sparkly';

sparkly([0, 3, 5, 8, 4, 3, 4, 10]);
//=> '▁▃▄▇▄▃▄█'

// Specifying anything other than finite numbers will cause holes
sparkly([0, 3, 5, '', 4, 3, 4, 10]);
//=> '▁▃▄ ▄▃▄█'

// Specifying an object with minimum and maximum options will change the sparkline range
sparkly([1, 2, 3, 4, 5], {minimum: 0, maximum: 10});
//=> '▁▂▃▄▄'

// Specifying a style option will change the sparkline color
sparkly([1, 2, 3, 4, 5, 6, 7, 8], {style: 'fire'});
// ↓

API

sparkly(numbers, options?)

numbers

Type: number[]

The numbers to create the sparkline from.

options

Type: object

minimum

Type: number

Minimum range.

maximum

Type: number

Maximum range.

style

Type: string
Values: 'fire'

Style for the sparklines.

Related

sparkly's People

Contributors

asahaf avatar beatfreaker avatar bendingbender avatar nigelzor avatar richienb avatar samverschueren avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkly's Issues

Tweaks

  • Use latest AVA version
  • Use XO
  • Update readme to ES2015 (var -> const)

sparkly 25 45 looks weird

$ sparkly 25 45
▁█
$ 

WTF?

In fact, all sparklines consisting of two figures where the second number has approximately twice the values of the first looks weird.

issue with fire style

~ ❯❯❯ replem sparkly
Installed into REPL context:
 - [email protected] as sparkly
> sparkly([0, 0, 0], { style: 'fire' })
'NaN\u001b[0mNaN\u001b[0mNaN\u001b[0m'
> sparkly([0, 1, 0], { style: 'fire' })
'\u001b[38;5;230m▁\u001b[0m\u001b[38;5;196m█\u001b[0m\u001b[38;5;230m▁\u001b[0m'
> sparkly([0, 0, 0])
''

output with all zeroes is weird

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.