Skip to content

Commit

Permalink
feat(stream): add stories on stream chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Aug 10, 2017
1 parent 986c66d commit 751d442
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 6 deletions.
32 changes: 27 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
src
.travis.yml
.babelrc
npm-debug.log*
# src (will be transpiled)
/src

# logs
*.log*

# OSX
.DS_Store
ISSUE_TEMPLATE.md

# github
/.github

# config/build
/build
.babelrc

# storybook
/.storybook
/stories
/storybook-static

# test
.travis.yml
/coverage
/test

# assets
nivo.png
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nivo",
"version": "0.8.0",
"version": "0.9.0",
"licenses": [
{
"type": "MIT",
Expand Down
102 changes: 102 additions & 0 deletions stories/charts/stream.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React from 'react'
import { range, random } from 'lodash'
import { storiesOf } from '@storybook/react'
import { withKnobs, boolean, select } from '@storybook/addon-knobs'
import '../style.css'
import { Stream, areaCurvePropKeys } from '../../src'

const keys = ['Raoul', 'Josiane', 'Marcel', 'René', 'Paul', 'Jacques']

const commonProperties = {
width: 900,
height: 360,
margin: { top: 60, right: 80, bottom: 60, left: 80 },
keys,
data: range(16).map(() =>
keys.reduce((layer, key) => {
layer[key] = random(10, 200)
return layer
}, {})
),
animate: true,
}

const stories = storiesOf('Stream', module)

stories
.addDecorator(story =>
<div className="wrapper">
{story()}
</div>
)
.addDecorator(withKnobs)

stories.add('default', () => <Stream {...commonProperties} />)

stories.add('full height (expand offset)', () =>
<Stream
{...commonProperties}
offsetType="expand"
curve={select('curve', areaCurvePropKeys, 'catmullRom')}
/>
)

stories.add('regular stacked chart', () =>
<Stream
{...commonProperties}
offsetType="none"
axisLeft={{}}
curve={select('curve', areaCurvePropKeys, 'catmullRom')}
/>
)

stories.add('custom curve', () => <Stream {...commonProperties} curve="step" />)

/*
stories.add('stacked', () =>
<Line {...commonProperties} stacked={true} curve={select('curve', curveOptions, 'linear')} />
)
stories.add('with custom curve', () =>
<Line {...commonProperties} stacked={true} curve="monotoneX" />
)
stories.add('with markers label', () =>
<Line
{...commonProperties}
stacked={boolean('stacked', true)}
curve={select('curve', curveOptions, 'linear')}
enableMarkersLabel={true}
markersSize={10}
markersBorderColor="#fff"
markersBorderWidth={2}
/>
)
stories.add('abusing markers label', () =>
<Line
{...commonProperties}
stacked={boolean('stacked', true)}
curve={select('curve', curveOptions, 'monotoneX')}
enableMarkersLabel={true}
markersSize={26}
markersLabelYOffset={3}
axisLeft={{
tickSize: 10,
}}
/>
)
stories.add('using data colors', () =>
<Line
{...commonProperties}
stacked={boolean('stacked', true)}
curve={select('curve', curveOptions, 'linear')}
colorBy={d => d.color}
enableMarkersLabel={true}
markersSize={10}
markersBorderColor="#fff"
markersBorderWidth={2}
/>
)
*/

0 comments on commit 751d442

Please sign in to comment.