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.
Files changed (71) hide show
  1. package/README.md +13 -12
  2. package/dist/victory-core.js +1083 -842
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-animation/victory-animation.js +26 -21
  5. package/es/victory-label/victory-label.js +8 -2
  6. package/es/victory-primitives/path-helpers.js +1 -1
  7. package/es/victory-transition/victory-transition.js +11 -6
  8. package/es/victory-util/add-events.js +66 -38
  9. package/es/victory-util/axis.js +35 -9
  10. package/es/victory-util/data.js +24 -9
  11. package/es/victory-util/domain.js +15 -7
  12. package/es/victory-util/events.js +1 -1
  13. package/es/victory-util/helpers.js +17 -5
  14. package/es/victory-util/label-helpers.js +3 -5
  15. package/es/victory-util/textsize.js +20 -20
  16. package/es/victory-util/transitions.js +16 -16
  17. package/es/victory-util/wrapper.js +56 -19
  18. package/lib/victory-animation/victory-animation.js +27 -21
  19. package/lib/victory-label/victory-label.js +8 -2
  20. package/lib/victory-primitives/path-helpers.js +1 -1
  21. package/lib/victory-transition/victory-transition.js +12 -6
  22. package/lib/victory-util/add-events.js +66 -38
  23. package/lib/victory-util/axis.js +36 -9
  24. package/lib/victory-util/data.js +25 -9
  25. package/lib/victory-util/domain.js +16 -8
  26. package/lib/victory-util/events.js +1 -1
  27. package/lib/victory-util/helpers.js +17 -5
  28. package/lib/victory-util/label-helpers.js +3 -5
  29. package/lib/victory-util/textsize.js +20 -20
  30. package/lib/victory-util/transitions.js +16 -16
  31. package/lib/victory-util/wrapper.js +56 -19
  32. package/package.json +1 -1
  33. package/src/victory-animation/util.js +47 -45
  34. package/src/victory-animation/victory-animation.js +66 -38
  35. package/src/victory-clip-container/victory-clip-container.js +44 -31
  36. package/src/victory-container/victory-container.js +35 -21
  37. package/src/victory-label/victory-label.js +55 -71
  38. package/src/victory-portal/portal.js +1 -1
  39. package/src/victory-portal/victory-portal.js +10 -7
  40. package/src/victory-primitives/arc.js +15 -4
  41. package/src/victory-primitives/border.js +26 -5
  42. package/src/victory-primitives/circle.js +14 -3
  43. package/src/victory-primitives/clip-path.js +2 -7
  44. package/src/victory-primitives/line-segment.js +28 -5
  45. package/src/victory-primitives/line.js +15 -2
  46. package/src/victory-primitives/path-helpers.js +6 -7
  47. package/src/victory-primitives/point.js +30 -11
  48. package/src/victory-primitives/rect.js +19 -3
  49. package/src/victory-primitives/text.js +21 -11
  50. package/src/victory-primitives/tspan.js +6 -4
  51. package/src/victory-primitives/whisker.js +13 -6
  52. package/src/victory-theme/grayscale.js +153 -128
  53. package/src/victory-theme/material.js +178 -149
  54. package/src/victory-transition/victory-transition.js +31 -25
  55. package/src/victory-util/add-events.js +113 -75
  56. package/src/victory-util/axis.js +89 -35
  57. package/src/victory-util/collection.js +3 -8
  58. package/src/victory-util/common-props.js +42 -36
  59. package/src/victory-util/data.js +78 -43
  60. package/src/victory-util/domain.js +68 -46
  61. package/src/victory-util/events.js +129 -112
  62. package/src/victory-util/helpers.js +36 -16
  63. package/src/victory-util/immutable.js +12 -7
  64. package/src/victory-util/label-helpers.js +34 -18
  65. package/src/victory-util/prop-types.js +11 -23
  66. package/src/victory-util/scale.js +2 -3
  67. package/src/victory-util/selection.js +4 -5
  68. package/src/victory-util/style.js +17 -10
  69. package/src/victory-util/textsize.js +35 -31
  70. package/src/victory-util/transitions.js +53 -35
  71. 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
- style: {
63
- data: {
64
- fill: grey900
65
- },
66
- labels: centeredLabelStyles
67
- }
68
- }, baseProps),
69
- axis: assign({
70
- style: {
71
- axis: {
72
- fill: "transparent",
73
- stroke: blueGrey300,
74
- strokeWidth: 2,
75
- strokeLinecap,
76
- strokeLinejoin
77
- },
78
- axisLabel: assign({}, centeredLabelStyles, {
79
- padding,
80
- stroke: "transparent"
81
- }),
82
- grid: {
83
- fill: "none",
84
- stroke: blueGrey50,
85
- strokeDasharray,
86
- strokeLinecap,
87
- strokeLinejoin,
88
- pointerEvents: "painted"
89
- },
90
- ticks: {
91
- fill: "transparent",
92
- size: 5,
93
- stroke: blueGrey300,
94
- strokeWidth: 1,
95
- strokeLinecap,
96
- strokeLinejoin
97
- },
98
- tickLabels: assign({}, baseLabelStyles, {
99
- fill: blueGrey700
100
- })
101
- }
102
- }, baseProps),
103
- bar: assign({
104
- style: {
105
- data: {
106
- fill: blueGrey700,
107
- padding,
108
- strokeWidth: 0
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
- labels: baseLabelStyles
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
- boxWidth: 20
127
- }, baseProps),
128
- candlestick: assign({
129
- style: {
130
- data: {
131
- stroke: blueGrey700
131
+ baseProps
132
+ ),
133
+ candlestick: assign(
134
+ {
135
+ style: {
136
+ data: {
137
+ stroke: blueGrey700
138
+ },
139
+ labels: centeredLabelStyles
132
140
  },
133
- labels: centeredLabelStyles
141
+ candleColors: {
142
+ positive: "#ffffff",
143
+ negative: blueGrey700
144
+ }
134
145
  },
135
- candleColors: {
136
- positive: "#ffffff",
137
- negative: blueGrey700
138
- }
139
- }, baseProps),
146
+ baseProps
147
+ ),
140
148
  chart: baseProps,
141
- errorbar: assign({
142
- borderWidth: 8,
143
- style: {
144
- data: {
145
- fill: "transparent",
146
- opacity: 1,
147
- stroke: blueGrey700,
148
- strokeWidth: 2
149
- },
150
- labels: centeredLabelStyles
151
- }
152
- }, baseProps),
153
- group: assign({
154
- colorScale: colors
155
- }, baseProps),
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
- style: {
171
- data: {
172
- fill: "transparent",
173
- opacity: 1,
174
- stroke: blueGrey700,
175
- strokeWidth: 2
176
- },
177
- labels: centeredLabelStyles
178
- }
179
- }, baseProps),
180
- pie: assign({
181
- colorScale: colors,
182
- style: {
183
- data: {
184
- padding,
185
- stroke: blueGrey50,
186
- strokeWidth: 1
187
- },
188
- labels: assign({}, baseLabelStyles, { padding: 20 })
189
- }
190
- }, baseProps),
191
- scatter: assign({
192
- style: {
193
- data: {
194
- fill: blueGrey700,
195
- opacity: 1,
196
- stroke: "transparent",
197
- strokeWidth: 0
198
- },
199
- labels: centeredLabelStyles
200
- }
201
- }, baseProps),
202
- stack: assign({
203
- colorScale: colors
204
- }, baseProps),
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
- style: {
218
- data: {
219
- fill: "transparent",
220
- stroke: "transparent",
221
- strokeWidth: 0
222
- },
223
- labels: assign({}, centeredLabelStyles, { padding: 5, pointerEvents: "none" }),
224
- flyout: {
225
- stroke: grey900,
226
- strokeWidth: 1,
227
- fill: "#f0f0f0",
228
- pointerEvents: "none"
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
- }, baseProps)
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
- componentWillReceiveProps(nextProps) {
37
- this.getTimer().bypassAnimation();
38
- this.setState(
39
- this.getTransitionState(this.props, nextProps), () => this.getTimer().resumeAnimation()
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
- childProps.domain : childProps.domain && childProps.domain[axis];
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] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
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 : 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 = isObject(this.props.animate) && this.props.animate.getTransitions ?
139
- this.props.animate.getTransitions :
140
- Transitions.getTransitionPropsFactory(
141
- props,
142
- this.state,
143
- (newState) => this.setState(newState)
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
- child.props.groupComponent,
164
- { clipWidth: newProps.clipWidth || 0 }
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, defaults({ animate: null, animating: true }, newProps, combinedProps)
178
+ child,
179
+ defaults({ animate: null, animating: true }, newProps, combinedProps)
174
180
  );
175
181
  }}
176
182
  </VictoryAnimation>