1
1
import range from 'lodash/range'
2
2
import random from 'lodash/random'
3
- import { storiesOf } from '@storybook/react'
3
+ import { Meta } from '@storybook/react'
4
4
import { withKnobs , select } from '@storybook/addon-knobs'
5
+ // @ts -ignore
5
6
import { areaCurvePropKeys } from '@nivo/core'
7
+ // @ts -ignore
6
8
import { Stream } from '../src'
7
9
10
+ export default {
11
+ component : Stream ,
12
+ title : 'Stream' ,
13
+ decorators : [ withKnobs ] ,
14
+ } as Meta
15
+
8
16
const keys = [ 'Raoul' , 'Josiane' , 'Marcel' , 'René' , 'Paul' , 'Jacques' ]
9
17
10
18
const commonProperties = {
@@ -16,35 +24,31 @@ const commonProperties = {
16
24
keys . reduce ( ( layer , key ) => {
17
25
layer [ key ] = random ( 10 , 200 )
18
26
return layer
19
- } , { } )
27
+ } , { } as any )
20
28
) ,
21
29
animate : true ,
22
30
}
23
31
24
- const stories = storiesOf ( 'Stream' , module )
25
-
26
- stories . addDecorator ( withKnobs )
27
-
28
- stories . add ( 'default' , ( ) => < Stream { ...commonProperties } /> )
32
+ export const Default = ( ) => < Stream { ...commonProperties } />
29
33
30
34
const labelLookup = {
31
35
al : 'Alabama' ,
32
36
az : 'Arizona' ,
33
37
nv : 'Nevada' ,
34
38
}
35
39
36
- stories . add ( 'custom label' , ( ) => (
40
+ export const CustomLabel = ( ) => (
37
41
< Stream
38
42
{ ...commonProperties }
39
43
data = { range ( 16 ) . map ( ( ) =>
40
44
Object . keys ( labelLookup ) . reduce ( ( layer , key ) => {
41
45
layer [ key ] = random ( 10 , 200 )
42
46
return layer
43
- } , { } )
47
+ } , { } as any )
44
48
) }
45
49
keys = { Object . keys ( labelLookup ) }
46
50
margin = { { top : 50 , right : 110 , bottom : 50 , left : 60 } }
47
- label = { d => labelLookup [ d . id ] }
51
+ label = { d => labelLookup [ d . id as keyof typeof labelLookup ] }
48
52
legends = { [
49
53
{
50
54
anchor : 'bottom-right' ,
@@ -66,28 +70,28 @@ stories.add('custom label', () => (
66
70
} ,
67
71
] }
68
72
/>
69
- ) )
73
+ )
70
74
71
- stories . add ( 'full height (expand offset)' , ( ) => (
75
+ export const fullHeight = ( ) => (
72
76
< Stream
73
77
{ ...commonProperties }
74
78
offsetType = "expand"
75
79
curve = { select ( 'curve' , areaCurvePropKeys , 'catmullRom' ) }
76
80
/>
77
- ) )
81
+ )
78
82
79
- stories . add ( 'regular stacked chart' , ( ) => (
83
+ export const regularStackedChart = ( ) => (
80
84
< Stream
81
85
{ ...commonProperties }
82
86
offsetType = "none"
83
87
axisLeft = { { } }
84
88
curve = { select ( 'curve' , areaCurvePropKeys , 'catmullRom' ) }
85
89
/>
86
- ) )
90
+ )
87
91
88
- stories . add ( 'custom curve' , ( ) => < Stream { ...commonProperties } curve = "step" /> )
92
+ export const CustomCurve = ( ) => < Stream { ...commonProperties } curve = "step" />
89
93
90
- stories . add ( 'formatting values' , ( ) => (
94
+ export const formattingValues = ( ) => (
91
95
< Stream
92
96
{ ...commonProperties }
93
97
valueFormat = { value =>
@@ -96,4 +100,4 @@ stories.add('formatting values', () => (
96
100
} ) } ₽`
97
101
}
98
102
/>
99
- ) )
103
+ )
0 commit comments