1 | # ![sparkly](https://cloud.githubusercontent.com/assets/170270/4068189/1b47cab0-2e36-11e4-8b75-16b80330147e.gif) [![Build Status](https://travis-ci.org/sindresorhus/sparkly.svg?branch=master)](https://travis-ci.org/sindresorhus/sparkly)
|
2 |
|
3 | > Generate sparklines ▁▂▃▅▂▇
|
4 |
|
5 | JavaScript port of [spark.sh](https://github.com/holman/spark).
|
6 |
|
7 | [Some cool use-cases.](https://github.com/holman/spark/wiki/Wicked-Cool-Usage)
|
8 |
|
9 |
|
10 | ## Install
|
11 |
|
12 | ```
|
13 | $ npm install --save sparkly
|
14 | ```
|
15 |
|
16 |
|
17 | ## Usage
|
18 |
|
19 | ```js
|
20 | const sparkly = require('sparkly');
|
21 |
|
22 | sparkly([0, 3, 5, 8, 4, 3, 4, 10]);
|
23 | //=> '▁▃▄▇▄▃▄█'
|
24 |
|
25 | // specifying anything other than finite numbers will cause holes
|
26 | sparkly([0, 3, 5, '', 4, 3, 4, 10]);
|
27 | //=> '▁▃▄ ▄▃▄█'
|
28 |
|
29 | // specifying a min max object will change the sparkline range
|
30 | sparkly([1, 2, 3, 4, 5], {min: 0, max: 10});
|
31 | //=> '▁▂▃▄▄'
|
32 | ```
|
33 |
|
34 | ## API
|
35 |
|
36 | ### sparkly(numbers, [options])
|
37 |
|
38 | #### numbers
|
39 |
|
40 | Type: `array` of `number`
|
41 |
|
42 | Numbers to create the sparkline from.
|
43 |
|
44 | #### options
|
45 |
|
46 | ##### min
|
47 |
|
48 | Type: `number`
|
49 |
|
50 | Minimum range.
|
51 |
|
52 | ##### max
|
53 |
|
54 | Type: `number`
|
55 |
|
56 | Maximum range.
|
57 |
|
58 |
|
59 | ## Related
|
60 |
|
61 | - [sparkly-cli](https://github.com/sindresorhus/sparkly-cli) - CLI for this module
|
62 |
|
63 |
|
64 | ## License
|
65 |
|
66 | MIT © [Sindre Sorhus](http://sindresorhus.com)
|