victory-core 30.6.1 → 31.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/dist/victory-core.js +1083 -842
- package/dist/victory-core.min.js +1 -1
- package/es/victory-animation/victory-animation.js +26 -21
- package/es/victory-label/victory-label.js +8 -2
- package/es/victory-primitives/path-helpers.js +1 -1
- package/es/victory-transition/victory-transition.js +11 -6
- package/es/victory-util/add-events.js +66 -38
- package/es/victory-util/axis.js +35 -9
- package/es/victory-util/data.js +24 -9
- package/es/victory-util/domain.js +15 -7
- package/es/victory-util/events.js +1 -1
- package/es/victory-util/helpers.js +17 -5
- package/es/victory-util/label-helpers.js +3 -5
- package/es/victory-util/textsize.js +20 -20
- package/es/victory-util/transitions.js +16 -16
- package/es/victory-util/wrapper.js +56 -19
- package/lib/victory-animation/victory-animation.js +27 -21
- package/lib/victory-label/victory-label.js +8 -2
- package/lib/victory-primitives/path-helpers.js +1 -1
- package/lib/victory-transition/victory-transition.js +12 -6
- package/lib/victory-util/add-events.js +66 -38
- package/lib/victory-util/axis.js +36 -9
- package/lib/victory-util/data.js +25 -9
- package/lib/victory-util/domain.js +16 -8
- package/lib/victory-util/events.js +1 -1
- package/lib/victory-util/helpers.js +17 -5
- package/lib/victory-util/label-helpers.js +3 -5
- package/lib/victory-util/textsize.js +20 -20
- package/lib/victory-util/transitions.js +16 -16
- package/lib/victory-util/wrapper.js +56 -19
- package/package.json +1 -1
- package/src/victory-animation/util.js +47 -45
- package/src/victory-animation/victory-animation.js +66 -38
- package/src/victory-clip-container/victory-clip-container.js +44 -31
- package/src/victory-container/victory-container.js +35 -21
- package/src/victory-label/victory-label.js +55 -71
- package/src/victory-portal/portal.js +1 -1
- package/src/victory-portal/victory-portal.js +10 -7
- package/src/victory-primitives/arc.js +15 -4
- package/src/victory-primitives/border.js +26 -5
- package/src/victory-primitives/circle.js +14 -3
- package/src/victory-primitives/clip-path.js +2 -7
- package/src/victory-primitives/line-segment.js +28 -5
- package/src/victory-primitives/line.js +15 -2
- package/src/victory-primitives/path-helpers.js +6 -7
- package/src/victory-primitives/point.js +30 -11
- package/src/victory-primitives/rect.js +19 -3
- package/src/victory-primitives/text.js +21 -11
- package/src/victory-primitives/tspan.js +6 -4
- package/src/victory-primitives/whisker.js +13 -6
- package/src/victory-theme/grayscale.js +153 -128
- package/src/victory-theme/material.js +178 -149
- package/src/victory-transition/victory-transition.js +31 -25
- package/src/victory-util/add-events.js +113 -75
- package/src/victory-util/axis.js +89 -35
- package/src/victory-util/collection.js +3 -8
- package/src/victory-util/common-props.js +42 -36
- package/src/victory-util/data.js +78 -43
- package/src/victory-util/domain.js +68 -46
- package/src/victory-util/events.js +129 -112
- package/src/victory-util/helpers.js +36 -16
- package/src/victory-util/immutable.js +12 -7
- package/src/victory-util/label-helpers.js +34 -18
- package/src/victory-util/prop-types.js +11 -23
- package/src/victory-util/scale.js +2 -3
- package/src/victory-util/selection.js +4 -5
- package/src/victory-util/style.js +17 -10
- package/src/victory-util/textsize.js +35 -31
- package/src/victory-util/transitions.js +53 -35
- package/src/victory-util/wrapper.js +112 -56
|
@@ -9,14 +9,7 @@ const lime300 = "#DCE775";
|
|
|
9
9
|
const lightGreen500 = "#8BC34A";
|
|
10
10
|
const teal700 = "#00796B";
|
|
11
11
|
const cyan900 = "#006064";
|
|
12
|
-
const colors = [
|
|
13
|
-
deepOrange600,
|
|
14
|
-
yellow200,
|
|
15
|
-
lime300,
|
|
16
|
-
lightGreen500,
|
|
17
|
-
teal700,
|
|
18
|
-
cyan900
|
|
19
|
-
];
|
|
12
|
+
const colors = [deepOrange600, yellow200, lime300, lightGreen500, teal700, cyan900];
|
|
20
13
|
const blueGrey50 = "#ECEFF1";
|
|
21
14
|
const blueGrey300 = "#90A4AE";
|
|
22
15
|
const blueGrey700 = "#455A64";
|
|
@@ -58,101 +51,122 @@ const strokeLinecap = "round";
|
|
|
58
51
|
const strokeLinejoin = "round";
|
|
59
52
|
|
|
60
53
|
export default {
|
|
61
|
-
area: assign(
|
|
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
|
-
|
|
54
|
+
area: assign(
|
|
55
|
+
{
|
|
56
|
+
style: {
|
|
57
|
+
data: {
|
|
58
|
+
fill: grey900
|
|
59
|
+
},
|
|
60
|
+
labels: centeredLabelStyles
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
baseProps
|
|
64
|
+
),
|
|
65
|
+
axis: assign(
|
|
66
|
+
{
|
|
67
|
+
style: {
|
|
68
|
+
axis: {
|
|
69
|
+
fill: "transparent",
|
|
70
|
+
stroke: blueGrey300,
|
|
71
|
+
strokeWidth: 2,
|
|
72
|
+
strokeLinecap,
|
|
73
|
+
strokeLinejoin
|
|
74
|
+
},
|
|
75
|
+
axisLabel: assign({}, centeredLabelStyles, {
|
|
76
|
+
padding,
|
|
77
|
+
stroke: "transparent"
|
|
78
|
+
}),
|
|
79
|
+
grid: {
|
|
80
|
+
fill: "none",
|
|
81
|
+
stroke: blueGrey50,
|
|
82
|
+
strokeDasharray,
|
|
83
|
+
strokeLinecap,
|
|
84
|
+
strokeLinejoin,
|
|
85
|
+
pointerEvents: "painted"
|
|
86
|
+
},
|
|
87
|
+
ticks: {
|
|
88
|
+
fill: "transparent",
|
|
89
|
+
size: 5,
|
|
90
|
+
stroke: blueGrey300,
|
|
91
|
+
strokeWidth: 1,
|
|
92
|
+
strokeLinecap,
|
|
93
|
+
strokeLinejoin
|
|
94
|
+
},
|
|
95
|
+
tickLabels: assign({}, baseLabelStyles, {
|
|
96
|
+
fill: blueGrey700
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
baseProps
|
|
101
|
+
),
|
|
102
|
+
bar: assign(
|
|
103
|
+
{
|
|
104
|
+
style: {
|
|
105
|
+
data: {
|
|
106
|
+
fill: blueGrey700,
|
|
107
|
+
padding,
|
|
108
|
+
strokeWidth: 0
|
|
109
|
+
},
|
|
110
|
+
labels: baseLabelStyles
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
baseProps
|
|
114
|
+
),
|
|
115
|
+
boxplot: assign(
|
|
116
|
+
{
|
|
117
|
+
style: {
|
|
118
|
+
max: { padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
119
|
+
maxLabels: baseLabelStyles,
|
|
120
|
+
median: { padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
121
|
+
medianLabels: baseLabelStyles,
|
|
122
|
+
min: { padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
123
|
+
minLabels: baseLabelStyles,
|
|
124
|
+
q1: { padding, fill: blueGrey700 },
|
|
125
|
+
q1Labels: baseLabelStyles,
|
|
126
|
+
q3: { padding, fill: blueGrey700 },
|
|
127
|
+
q3Labels: baseLabelStyles
|
|
109
128
|
},
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
}, baseProps),
|
|
113
|
-
boxplot: assign({
|
|
114
|
-
style: {
|
|
115
|
-
max: { padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
116
|
-
maxLabels: baseLabelStyles,
|
|
117
|
-
median: { padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
118
|
-
medianLabels: baseLabelStyles,
|
|
119
|
-
min: { padding, stroke: blueGrey700, strokeWidth: 1 },
|
|
120
|
-
minLabels: baseLabelStyles,
|
|
121
|
-
q1: { padding, fill: blueGrey700 },
|
|
122
|
-
q1Labels: baseLabelStyles,
|
|
123
|
-
q3: { padding, fill: blueGrey700 },
|
|
124
|
-
q3Labels: baseLabelStyles
|
|
129
|
+
boxWidth: 20
|
|
125
130
|
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
candlestick: assign(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
baseProps
|
|
132
|
+
),
|
|
133
|
+
candlestick: assign(
|
|
134
|
+
{
|
|
135
|
+
style: {
|
|
136
|
+
data: {
|
|
137
|
+
stroke: blueGrey700
|
|
138
|
+
},
|
|
139
|
+
labels: centeredLabelStyles
|
|
132
140
|
},
|
|
133
|
-
|
|
141
|
+
candleColors: {
|
|
142
|
+
positive: "#ffffff",
|
|
143
|
+
negative: blueGrey700
|
|
144
|
+
}
|
|
134
145
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
negative: blueGrey700
|
|
138
|
-
}
|
|
139
|
-
}, baseProps),
|
|
146
|
+
baseProps
|
|
147
|
+
),
|
|
140
148
|
chart: baseProps,
|
|
141
|
-
errorbar: assign(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
errorbar: assign(
|
|
150
|
+
{
|
|
151
|
+
borderWidth: 8,
|
|
152
|
+
style: {
|
|
153
|
+
data: {
|
|
154
|
+
fill: "transparent",
|
|
155
|
+
opacity: 1,
|
|
156
|
+
stroke: blueGrey700,
|
|
157
|
+
strokeWidth: 2
|
|
158
|
+
},
|
|
159
|
+
labels: centeredLabelStyles
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
baseProps
|
|
163
|
+
),
|
|
164
|
+
group: assign(
|
|
165
|
+
{
|
|
166
|
+
colorScale: colors
|
|
167
|
+
},
|
|
168
|
+
baseProps
|
|
169
|
+
),
|
|
156
170
|
legend: {
|
|
157
171
|
colorScale: colors,
|
|
158
172
|
gutter: 10,
|
|
@@ -166,42 +180,54 @@ export default {
|
|
|
166
180
|
title: assign({}, baseLabelStyles, { padding: 5 })
|
|
167
181
|
}
|
|
168
182
|
},
|
|
169
|
-
line: assign(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
183
|
+
line: assign(
|
|
184
|
+
{
|
|
185
|
+
style: {
|
|
186
|
+
data: {
|
|
187
|
+
fill: "transparent",
|
|
188
|
+
opacity: 1,
|
|
189
|
+
stroke: blueGrey700,
|
|
190
|
+
strokeWidth: 2
|
|
191
|
+
},
|
|
192
|
+
labels: centeredLabelStyles
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
baseProps
|
|
196
|
+
),
|
|
197
|
+
pie: assign(
|
|
198
|
+
{
|
|
199
|
+
colorScale: colors,
|
|
200
|
+
style: {
|
|
201
|
+
data: {
|
|
202
|
+
padding,
|
|
203
|
+
stroke: blueGrey50,
|
|
204
|
+
strokeWidth: 1
|
|
205
|
+
},
|
|
206
|
+
labels: assign({}, baseLabelStyles, { padding: 20 })
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
baseProps
|
|
210
|
+
),
|
|
211
|
+
scatter: assign(
|
|
212
|
+
{
|
|
213
|
+
style: {
|
|
214
|
+
data: {
|
|
215
|
+
fill: blueGrey700,
|
|
216
|
+
opacity: 1,
|
|
217
|
+
stroke: "transparent",
|
|
218
|
+
strokeWidth: 0
|
|
219
|
+
},
|
|
220
|
+
labels: centeredLabelStyles
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
baseProps
|
|
224
|
+
),
|
|
225
|
+
stack: assign(
|
|
226
|
+
{
|
|
227
|
+
colorScale: colors
|
|
228
|
+
},
|
|
229
|
+
baseProps
|
|
230
|
+
),
|
|
205
231
|
tooltip: {
|
|
206
232
|
style: assign({}, centeredLabelStyles, { padding: 5, pointerEvents: "none" }),
|
|
207
233
|
flyoutStyle: {
|
|
@@ -213,20 +239,23 @@ export default {
|
|
|
213
239
|
cornerRadius: 5,
|
|
214
240
|
pointerLength: 10
|
|
215
241
|
},
|
|
216
|
-
voronoi: assign(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
242
|
+
voronoi: assign(
|
|
243
|
+
{
|
|
244
|
+
style: {
|
|
245
|
+
data: {
|
|
246
|
+
fill: "transparent",
|
|
247
|
+
stroke: "transparent",
|
|
248
|
+
strokeWidth: 0
|
|
249
|
+
},
|
|
250
|
+
labels: assign({}, centeredLabelStyles, { padding: 5, pointerEvents: "none" }),
|
|
251
|
+
flyout: {
|
|
252
|
+
stroke: grey900,
|
|
253
|
+
strokeWidth: 1,
|
|
254
|
+
fill: "#f0f0f0",
|
|
255
|
+
pointerEvents: "none"
|
|
256
|
+
}
|
|
229
257
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
258
|
+
},
|
|
259
|
+
baseProps
|
|
260
|
+
)
|
|
232
261
|
};
|
|
@@ -6,6 +6,7 @@ import Helpers from "../victory-util/helpers";
|
|
|
6
6
|
import Timer from "../victory-util/timer";
|
|
7
7
|
import Transitions from "../victory-util/transitions";
|
|
8
8
|
import { defaults, isFunction, pick, isObject } from "lodash";
|
|
9
|
+
import isEqual from "react-fast-compare";
|
|
9
10
|
|
|
10
11
|
export default class VictoryTransition extends React.Component {
|
|
11
12
|
static displayName = "VictoryTransition";
|
|
@@ -33,11 +34,14 @@ export default class VictoryTransition extends React.Component {
|
|
|
33
34
|
this.setState({ nodesShouldLoad: true }); //eslint-disable-line react/no-did-mount-set-state
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
this.getTransitionState(this.props, nextProps), () =>
|
|
40
|
-
|
|
37
|
+
shouldComponentUpdate(nextProps) {
|
|
38
|
+
if (!isEqual(this.props, nextProps)) {
|
|
39
|
+
this.getTimer().bypassAnimation();
|
|
40
|
+
this.setState(this.getTransitionState(this.props, nextProps), () =>
|
|
41
|
+
this.getTimer().resumeAnimation()
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
componentWillUnmount() {
|
|
@@ -97,14 +101,16 @@ export default class VictoryTransition extends React.Component {
|
|
|
97
101
|
|
|
98
102
|
const child = React.Children.toArray(props.children)[0];
|
|
99
103
|
const childProps = child.props || {};
|
|
100
|
-
const domain = Array.isArray(childProps.domain)
|
|
101
|
-
|
|
104
|
+
const domain = Array.isArray(childProps.domain)
|
|
105
|
+
? childProps.domain
|
|
106
|
+
: childProps.domain && childProps.domain[axis];
|
|
102
107
|
if (!childProps.children && domain) {
|
|
103
108
|
return domain;
|
|
104
109
|
} else {
|
|
105
110
|
const childDomains = getChildDomains([child]);
|
|
106
|
-
return childDomains.length === 0
|
|
107
|
-
[0, 1]
|
|
111
|
+
return childDomains.length === 0
|
|
112
|
+
? [0, 1]
|
|
113
|
+
: [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
|
|
@@ -118,8 +124,9 @@ export default class VictoryTransition extends React.Component {
|
|
|
118
124
|
pickDomainProps(props) {
|
|
119
125
|
const parentState = isObject(props.animate) && props.animate.parentState;
|
|
120
126
|
if (parentState && parentState.nodesWillExit) {
|
|
121
|
-
return this.continous || parentState.continuous
|
|
122
|
-
parentState.nextProps || this.state.nextProps || props
|
|
127
|
+
return this.continous || parentState.continuous
|
|
128
|
+
? parentState.nextProps || this.state.nextProps || props
|
|
129
|
+
: props;
|
|
123
130
|
}
|
|
124
131
|
return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
|
|
125
132
|
}
|
|
@@ -135,13 +142,12 @@ export default class VictoryTransition extends React.Component {
|
|
|
135
142
|
|
|
136
143
|
render() {
|
|
137
144
|
const props = this.pickProps();
|
|
138
|
-
const getTransitionProps =
|
|
139
|
-
this.props.animate.getTransitions
|
|
140
|
-
|
|
141
|
-
props,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
);
|
|
145
|
+
const getTransitionProps =
|
|
146
|
+
isObject(this.props.animate) && this.props.animate.getTransitions
|
|
147
|
+
? this.props.animate.getTransitions
|
|
148
|
+
: Transitions.getTransitionPropsFactory(props, this.state, (newState) =>
|
|
149
|
+
this.setState(newState)
|
|
150
|
+
);
|
|
145
151
|
const child = React.Children.toArray(props.children)[0];
|
|
146
152
|
const transitionProps = getTransitionProps(child);
|
|
147
153
|
this.transitionProps = transitionProps;
|
|
@@ -158,19 +164,19 @@ export default class VictoryTransition extends React.Component {
|
|
|
158
164
|
<VictoryAnimation {...combinedProps.animate} data={propsToAnimate}>
|
|
159
165
|
{(newProps) => {
|
|
160
166
|
if (child.props.groupComponent) {
|
|
161
|
-
const groupComponent = this.continuous
|
|
162
|
-
React.cloneElement(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
child.props.groupComponent;
|
|
167
|
+
const groupComponent = this.continuous
|
|
168
|
+
? React.cloneElement(child.props.groupComponent, {
|
|
169
|
+
clipWidth: newProps.clipWidth || 0
|
|
170
|
+
})
|
|
171
|
+
: child.props.groupComponent;
|
|
167
172
|
return React.cloneElement(
|
|
168
173
|
child,
|
|
169
174
|
defaults({ animate: null, animating: true, groupComponent }, newProps, combinedProps)
|
|
170
175
|
);
|
|
171
176
|
}
|
|
172
177
|
return React.cloneElement(
|
|
173
|
-
child,
|
|
178
|
+
child,
|
|
179
|
+
defaults({ animate: null, animating: true }, newProps, combinedProps)
|
|
174
180
|
);
|
|
175
181
|
}}
|
|
176
182
|
</VictoryAnimation>
|