/
props.js
129 lines (112 loc) · 4.48 KB
/
props.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import PropTypes from 'prop-types'
import { motionPropTypes } from '@nivo/core'
import { ordinalColorsPropType, inheritedColorPropType } from '@nivo/colors'
import { axisPropType } from '@nivo/axes'
import LineTooltip from './LineTooltip'
import Point from './Point'
const commonPropTypes = {
data: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
data: PropTypes.arrayOf(
PropTypes.shape({
x: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
y: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
})
).isRequired,
})
).isRequired,
layers: PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.oneOf(['grid', 'axes', 'labels', 'lines', 'points']),
PropTypes.func,
])
).isRequired,
interpolation: PropTypes.oneOf(['linear', 'smooth']).isRequired,
xPadding: PropTypes.number.isRequired,
xOuterPadding: PropTypes.number.isRequired,
yOuterPadding: PropTypes.number.isRequired,
colors: ordinalColorsPropType.isRequired,
lineWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
activeLineWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
inactiveLineWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
opacity: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
activeOpacity: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
inactiveOpacity: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
startLabel: PropTypes.oneOfType([PropTypes.oneOf([false]), PropTypes.string, PropTypes.func])
.isRequired,
startLabelPadding: PropTypes.number.isRequired,
startLabelTextColor: inheritedColorPropType.isRequired,
endLabel: PropTypes.oneOfType([PropTypes.oneOf([false]), PropTypes.string, PropTypes.func])
.isRequired,
endLabelPadding: PropTypes.number.isRequired,
endLabelTextColor: inheritedColorPropType.isRequired,
pointComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
pointSize: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
activePointSize: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
inactivePointSize: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
pointColor: inheritedColorPropType.isRequired,
pointBorderWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
activePointBorderWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
inactivePointBorderWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).isRequired,
pointBorderColor: inheritedColorPropType.isRequired,
enableGridX: PropTypes.bool.isRequired,
enableGridY: PropTypes.bool.isRequired,
axisTop: axisPropType,
axisRight: axisPropType,
axisBottom: axisPropType,
axisLeft: axisPropType,
isInteractive: PropTypes.bool.isRequired,
onMouseEnter: PropTypes.func,
onMouseMove: PropTypes.func,
onMouseLeave: PropTypes.func,
onClick: PropTypes.func,
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
}
export const BumpPropTypes = {
...commonPropTypes,
...motionPropTypes,
role: PropTypes.string.isRequired,
}
const commonDefaultProps = {
layers: ['grid', 'axes', 'labels', 'lines', 'points'],
interpolation: 'smooth',
xPadding: 0.6,
xOuterPadding: 0.5,
yOuterPadding: 0.5,
colors: { scheme: 'nivo' },
lineWidth: 2,
activeLineWidth: 4,
inactiveLineWidth: 1,
opacity: 1,
activeOpacity: 1,
inactiveOpacity: 0.3,
startLabel: false,
startLabelPadding: 16,
startLabelTextColor: { from: 'color' },
endLabel: 'id',
endLabelPadding: 16,
endLabelTextColor: { from: 'color' },
pointSize: 6,
activePointSize: 8,
inactivePointSize: 4,
pointColor: { from: 'serie.color' },
pointBorderWidth: 0,
activePointBorderWidth: 0,
inactivePointBorderWidth: 0,
pointBorderColor: { from: 'serie.color', modifiers: [['darker', 1.4]] },
enableGridX: true,
enableGridY: true,
axisTop: {},
axisBottom: {},
axisLeft: {},
isInteractive: true,
tooltip: LineTooltip,
}
export const BumpDefaultProps = {
...commonDefaultProps,
pointComponent: Point,
animate: true,
motionConfig: 'gentle',
role: 'img',
}