0.2.1 • Published 5 years ago

stonks v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

stonks

Small form-factor line chart for React.

Screenshot

Installation

npm install stonks

Note: If using Typescript, npm install @types/stonks

Basic Usage

import * as React from 'react';
import Stonk from 'stonks';

const StonksDemo = () => {
    const data = [50, 35, 20, 21, 36, 51, 55, 61, 70, 60, 55, 60];
    return (
        <div>
            <Stonk data={data} />
        </div>
    );
}

Demo

To try out the component in a demo:

git clone git@github.com:curtisupshall/stonks.git
cd stonks
npm install
npm run demo-server

Then visit localhost:8080 in your browser.

Theming

The theme for each graph can be customized. Children passed to a <Stonk> instance will be passed to the SVG's <defs> element. The following <linearGradient> IDs are used:

idDescription
positive-gradientThe background gradient for positive graphs
negative-gradientThe background gradient for negative graphs
positive-lineThe stroke line gradient for positive graphs
negative-lineThe stroke line gradient for negative graphs
baselineThe stroke line gradient for the graph's baseline

Props

NameTypeDefaultDescription
datanumber[]-The data for the line plot
classNamestring'stonk'Optional className attribute
granularitynumber10The number of plots on the graph
heightnumber100The height of the graph (pixels)
isPositiveboolean-Overrides the styling for whether the net change of the graph is positive or negative
showBaselineboolean-Override whether or not the zero line is visible. By default, the line isn't shown unless the data prop contains negative values
widthnumber200The width of the graph (pixels)

Note: In the case when granularity is smaller than the data points provided, a select number of plots are shown. In the case that granularity is larger than the data provided, the graph is pushed to the right.

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago