@@ -3,21 +3,25 @@ import range from 'lodash/range'
3
3
import shuffle from 'lodash/shuffle'
4
4
import { graphql , useStaticQuery } from 'gatsby'
5
5
import { ResponsiveBump , bumpSvgDefaultProps as defaults , BumpCommonProps } from '@nivo/bump'
6
+ import { ModernMotionProps } from '@nivo/core'
7
+ import { AxisProps } from '@nivo/axes'
6
8
import { ComponentTemplate } from '../../components/components/ComponentTemplate'
7
9
import meta from '../../data/components/bump/meta.yml'
8
10
import { groups } from '../../data/components/bump/props'
9
11
import mapper from '../../data/components/bump/mapper'
10
12
13
+ interface Datum {
14
+ x : number
15
+ y : number
16
+ }
17
+
11
18
const generateData = ( ) => {
12
19
const years = range ( 2000 , 2005 )
13
20
const ranks = range ( 1 , 13 )
14
21
15
22
const series : {
16
23
id : string
17
- data : {
18
- x : number
19
- y : number
20
- } [ ]
24
+ data : Datum [ ]
21
25
} [ ] = ranks . map ( rank => {
22
26
return {
23
27
id : `Serie ${ rank } ` ,
@@ -37,38 +41,34 @@ const generateData = () => {
37
41
return series
38
42
}
39
43
40
- type UnmappedProps = Omit < BumpCommonProps < { x : number ; y : number } , { } > , 'whatever' >
41
-
42
- type Props = UnmappedProps
44
+ type Props = Omit <
45
+ BumpCommonProps < Datum , { } > ,
46
+ 'theme' | 'onMouseEnter' | 'onMouseMove' | 'onMouseLeave' | 'onClick' | 'renderWrapper'
47
+ > &
48
+ ModernMotionProps
49
+
50
+ type UnmappedProps = Omit < Props , 'axisTop' | 'axisRight' | 'axisBottom' | 'axisLeft' > & {
51
+ axisTop : AxisProps & { enable : boolean }
52
+ axisRight : AxisProps & { enable : boolean }
53
+ axisBottom : AxisProps & { enable : boolean }
54
+ axisLeft : AxisProps & { enable : boolean }
55
+ }
43
56
44
57
const initialProperties : UnmappedProps = {
58
+ ...defaults ,
45
59
margin : {
46
60
top : 40 ,
47
61
right : 100 ,
48
62
bottom : 40 ,
49
63
left : 60 ,
50
64
} ,
51
65
52
- interpolation : defaults . interpolation ,
53
- xPadding : defaults . xPadding ,
54
- xOuterPadding : defaults . xOuterPadding ,
55
- yOuterPadding : defaults . yOuterPadding ,
56
-
57
66
colors : { scheme : 'spectral' } ,
58
67
lineWidth : 3 ,
59
68
activeLineWidth : 6 ,
60
69
inactiveLineWidth : 3 ,
61
- opacity : defaults . opacity ,
62
- activeOpacity : defaults . activeOpacity ,
63
70
inactiveOpacity : 0.15 ,
64
71
65
- startLabel : false ,
66
- startLabelPadding : defaults . startLabelPadding ,
67
- startLabelTextColor : defaults . startLabelTextColor ,
68
- endLabel : true ,
69
- endLabelPadding : defaults . endLabelPadding ,
70
- endLabelTextColor : defaults . endLabelTextColor ,
71
-
72
72
pointSize : 10 ,
73
73
activePointSize : 16 ,
74
74
inactivePointSize : 0 ,
@@ -78,8 +78,6 @@ const initialProperties: UnmappedProps = {
78
78
inactivePointBorderWidth : 0 ,
79
79
pointBorderColor : { from : 'serie.color' } ,
80
80
81
- enableGridX : true ,
82
- enableGridY : true ,
83
81
axisTop : {
84
82
enable : true ,
85
83
tickSize : 5 ,
@@ -118,11 +116,6 @@ const initialProperties: UnmappedProps = {
118
116
legendPosition : 'middle' ,
119
117
legendOffset : - 40 ,
120
118
} ,
121
-
122
- isInteractive : true ,
123
-
124
- animate : defaults . animate ,
125
- motionConfig : defaults . motionConfig ,
126
119
}
127
120
128
121
const Bump = ( ) => {
@@ -156,7 +149,7 @@ const Bump = () => {
156
149
>
157
150
{ ( properties , data , theme , logAction ) => {
158
151
return (
159
- < ResponsiveBump < { x : number ; y : number } >
152
+ < ResponsiveBump < Datum >
160
153
data = { data }
161
154
{ ...properties }
162
155
theme = { theme }
0 commit comments