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
@@ -1,40 +1,40 @@
1
1
  import { interpolate } from "d3-interpolate";
2
2
  import { isPlainObject, orderBy } from "lodash";
3
3
 
4
- export const isInterpolatable = function (obj) {
4
+ export const isInterpolatable = function(obj) {
5
5
  // d3 turns null into 0 and undefined into NaN, which we don't want.
6
6
  if (obj !== null) {
7
7
  switch (typeof obj) {
8
- case "undefined":
9
- return false;
10
- case "number":
11
- // The standard `isNaN` is fine in this case since we already know the
12
- // type is number.
13
- return !isNaN(obj) && obj !== Number.POSITIVE_INFINITY && obj !== Number.NEGATIVE_INFINITY;
14
- case "string":
15
- // d3 might not *actually* be able to interpolate the string, but it
16
- // won't cause any issues to let it try.
17
- return true;
18
- case "boolean":
19
- // d3 turns Booleans into integers, which we don't want. Sure, we could
20
- // interpolate from 0 -> 1, but we'd be sending a non-Boolean to
21
- // something expecting a Boolean.
22
- return false;
23
- case "object":
24
- // Don't try to interpolate class instances (except Date or Array).
25
- return obj instanceof Date || Array.isArray(obj) || isPlainObject(obj);
26
- case "function":
27
- // Careful! There may be extra properties on function objects that the
28
- // component expects to access - for instance, it may be a `d3.scale()`
29
- // function, which has its own methods attached. We don't know if the
30
- // component is only going to call the function (in which case it's
31
- // safely interpolatable) or if it's going to access special properties
32
- // (in which case our function generated from `interpolateFunction` will
33
- // most likely cause an error. We could check for enumerable properties
34
- // on the function object here to see if it's a "plain" function, but
35
- // let's just require that components prevent such function props from
36
- // being animated in the first place.
37
- return true;
8
+ case "undefined":
9
+ return false;
10
+ case "number":
11
+ // The standard `isNaN` is fine in this case since we already know the
12
+ // type is number.
13
+ return !isNaN(obj) && obj !== Number.POSITIVE_INFINITY && obj !== Number.NEGATIVE_INFINITY;
14
+ case "string":
15
+ // d3 might not *actually* be able to interpolate the string, but it
16
+ // won't cause any issues to let it try.
17
+ return true;
18
+ case "boolean":
19
+ // d3 turns Booleans into integers, which we don't want. Sure, we could
20
+ // interpolate from 0 -> 1, but we'd be sending a non-Boolean to
21
+ // something expecting a Boolean.
22
+ return false;
23
+ case "object":
24
+ // Don't try to interpolate class instances (except Date or Array).
25
+ return obj instanceof Date || Array.isArray(obj) || isPlainObject(obj);
26
+ case "function":
27
+ // Careful! There may be extra properties on function objects that the
28
+ // component expects to access - for instance, it may be a `d3.scale()`
29
+ // function, which has its own methods attached. We don't know if the
30
+ // component is only going to call the function (in which case it's
31
+ // safely interpolatable) or if it's going to access special properties
32
+ // (in which case our function generated from `interpolateFunction` will
33
+ // most likely cause an error. We could check for enumerable properties
34
+ // on the function object here to see if it's a "plain" function, but
35
+ // let's just require that components prevent such function props from
36
+ // being animated in the first place.
37
+ return true;
38
38
  }
39
39
  }
40
40
  return false;
@@ -55,9 +55,9 @@ export const isInterpolatable = function (obj) {
55
55
  * @param {Number} when - Step value (0 to 1) at which to jump to `b`.
56
56
  * @returns {Function} An interpolation function.
57
57
  */
58
- export const interpolateImmediate = function (a, b, when = 0) {
59
- return function (t) {
60
- return (t < when) ? a : b;
58
+ export const interpolateImmediate = function(a, b, when = 0) {
59
+ return function(t) {
60
+ return t < when ? a : b;
61
61
  };
62
62
  };
63
63
 
@@ -73,15 +73,15 @@ export const interpolateImmediate = function (a, b, when = 0) {
73
73
  * @param {any} b - End value.
74
74
  * @returns {Function} An interpolation function.
75
75
  */
76
- export const interpolateFunction = function (a, b) {
77
- return function (t) {
76
+ export const interpolateFunction = function(a, b) {
77
+ return function(t) {
78
78
  if (t >= 1) {
79
79
  return b;
80
80
  }
81
- return function () {
81
+ return function() {
82
82
  /* eslint-disable no-invalid-this */
83
- const aval = (typeof a === "function") ? a.apply(this, arguments) : a;
84
- const bval = (typeof b === "function") ? b.apply(this, arguments) : b;
83
+ const aval = typeof a === "function" ? a.apply(this, arguments) : a;
84
+ const bval = typeof b === "function" ? b.apply(this, arguments) : b;
85
85
  return interpolate(aval, bval)(t);
86
86
  };
87
87
  };
@@ -97,7 +97,7 @@ export const interpolateFunction = function (a, b) {
97
97
  * @param {any} b - End value.
98
98
  * @returns {Function} An interpolation function.
99
99
  */
100
- export const interpolateObject = function (a, b) {
100
+ export const interpolateObject = function(a, b) {
101
101
  const interpolateTypes = (x, y) => {
102
102
  if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) {
103
103
  return interpolateImmediate(x, y);
@@ -105,7 +105,10 @@ export const interpolateObject = function (a, b) {
105
105
  if (typeof x === "function" || typeof y === "function") {
106
106
  return interpolateFunction(x, y);
107
107
  }
108
- if (typeof x === "object" && isPlainObject(x) || typeof y === "object" && isPlainObject(y)) {
108
+ if (
109
+ (typeof x === "object" && isPlainObject(x)) ||
110
+ (typeof y === "object" && isPlainObject(y))
111
+ ) {
109
112
  return interpolateObject(x, y);
110
113
  }
111
114
  return interpolate(x, y);
@@ -136,7 +139,7 @@ export const interpolateObject = function (a, b) {
136
139
  }
137
140
  }
138
141
 
139
- return function (t) {
142
+ return function(t) {
140
143
  for (k in i) {
141
144
  c[k] = i[k](t);
142
145
  }
@@ -144,7 +147,7 @@ export const interpolateObject = function (a, b) {
144
147
  };
145
148
  };
146
149
 
147
- export const interpolateString = function (a, b) {
150
+ export const interpolateString = function(a, b) {
148
151
  const format = (val) => {
149
152
  return typeof val === "string" ? val.replace(/,/g, "") : val;
150
153
  };
@@ -175,7 +178,7 @@ export const interpolateString = function (a, b) {
175
178
  * @param {any} b - End value.
176
179
  * @returns {Function|undefined} An interpolation function, if necessary.
177
180
  */
178
- export const victoryInterpolator = function (a, b) {
181
+ export const victoryInterpolator = function(a, b) {
179
182
  // If the values are strictly equal, or either value is not interpolatable,
180
183
  // just use either the start value `a` or end value `b` at every step, as
181
184
  // there is no reasonable in-between value.
@@ -193,4 +196,3 @@ export const victoryInterpolator = function (a, b) {
193
196
  }
194
197
  return interpolate(a, b);
195
198
  };
196
-
@@ -4,29 +4,57 @@ import PropTypes from "prop-types";
4
4
  import * as d3Ease from "d3-ease";
5
5
  import { victoryInterpolator } from "./util";
6
6
  import Timer from "../victory-util/timer";
7
+ import isEqual from "react-fast-compare";
7
8
 
8
9
  export default class VictoryAnimation extends React.Component {
9
10
  static displayName = "VictoryAnimation";
10
11
 
11
12
  static propTypes = {
12
13
  children: PropTypes.func,
13
- data: PropTypes.oneOfType([
14
- PropTypes.object,
15
- PropTypes.array
16
- ]),
14
+ data: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
17
15
  delay: PropTypes.number,
18
16
  duration: PropTypes.number,
19
17
  easing: PropTypes.oneOf([
20
- "back", "backIn", "backOut", "backInOut",
21
- "bounce", "bounceIn", "bounceOut", "bounceInOut",
22
- "circle", "circleIn", "circleOut", "circleInOut",
23
- "linear", "linearIn", "linearOut", "linearInOut",
24
- "cubic", "cubicIn", "cubicOut", "cubicInOut",
25
- "elastic", "elasticIn", "elasticOut", "elasticInOut",
26
- "exp", "expIn", "expOut", "expInOut",
27
- "poly", "polyIn", "polyOut", "polyInOut",
28
- "quad", "quadIn", "quadOut", "quadInOut",
29
- "sin", "sinIn", "sinOut", "sinInOut"
18
+ "back",
19
+ "backIn",
20
+ "backOut",
21
+ "backInOut",
22
+ "bounce",
23
+ "bounceIn",
24
+ "bounceOut",
25
+ "bounceInOut",
26
+ "circle",
27
+ "circleIn",
28
+ "circleOut",
29
+ "circleInOut",
30
+ "linear",
31
+ "linearIn",
32
+ "linearOut",
33
+ "linearInOut",
34
+ "cubic",
35
+ "cubicIn",
36
+ "cubicOut",
37
+ "cubicInOut",
38
+ "elastic",
39
+ "elasticIn",
40
+ "elasticOut",
41
+ "elasticInOut",
42
+ "exp",
43
+ "expIn",
44
+ "expOut",
45
+ "expInOut",
46
+ "poly",
47
+ "polyIn",
48
+ "polyOut",
49
+ "polyInOut",
50
+ "quad",
51
+ "quadIn",
52
+ "quadOut",
53
+ "quadInOut",
54
+ "sin",
55
+ "sinIn",
56
+ "sinOut",
57
+ "sinInOut"
30
58
  ]),
31
59
  onEnd: PropTypes.func
32
60
  };
@@ -46,16 +74,14 @@ export default class VictoryAnimation extends React.Component {
46
74
  super(props);
47
75
  /* defaults */
48
76
  this.state = {
49
- data: Array.isArray(this.props.data) ?
50
- this.props.data[0] : this.props.data,
77
+ data: Array.isArray(this.props.data) ? this.props.data[0] : this.props.data,
51
78
  animationInfo: {
52
79
  progress: 0,
53
80
  animating: false
54
81
  }
55
82
  };
56
83
  this.interpolator = null;
57
- this.queue = Array.isArray(this.props.data) ?
58
- this.props.data.slice(1) : [];
84
+ this.queue = Array.isArray(this.props.data) ? this.props.data.slice(1) : [];
59
85
  /* build easing function */
60
86
  this.ease = d3Ease[this.toNewName(this.props.easing)];
61
87
  /*
@@ -73,24 +99,27 @@ export default class VictoryAnimation extends React.Component {
73
99
  }
74
100
  }
75
101
 
76
- /* lifecycle */
77
- componentWillReceiveProps(nextProps) {
78
- /* cancel existing loop if it exists */
79
- this.getTimer().unsubscribe(this.loopID);
102
+ shouldComponentUpdate(nextProps, nextState) {
103
+ const equalProps = isEqual(this.props, nextProps);
104
+ if (!equalProps) {
105
+ /* cancel existing loop if it exists */
106
+ this.getTimer().unsubscribe(this.loopID);
80
107
 
81
- /* If an object was supplied */
82
- if (!Array.isArray(nextProps.data)) {
83
- // Replace the tween queue. Could set `this.queue = [nextProps.data]`,
84
- // but let's reuse the same array.
85
- this.queue.length = 0;
86
- this.queue.push(nextProps.data);
87
- /* If an array was supplied */
88
- } else {
89
- /* Extend the tween queue */
90
- this.queue.push(...nextProps.data);
108
+ /* If an object was supplied */
109
+ if (!Array.isArray(nextProps.data)) {
110
+ // Replace the tween queue. Could set `this.queue = [nextProps.data]`,
111
+ // but let's reuse the same array.
112
+ this.queue.length = 0;
113
+ this.queue.push(nextProps.data);
114
+ /* If an array was supplied */
115
+ } else {
116
+ /* Extend the tween queue */
117
+ this.queue.push(...nextProps.data);
118
+ }
119
+ /* Start traversing the tween queue */
120
+ this.traverseQueue();
91
121
  }
92
- /* Start traversing the tween queue */
93
- this.traverseQueue();
122
+ return nextState.animationInfo.animating || !equalProps;
94
123
  }
95
124
 
96
125
  componentWillUnmount() {
@@ -128,13 +157,12 @@ export default class VictoryAnimation extends React.Component {
128
157
  if (this.props.delay) {
129
158
  setTimeout(() => {
130
159
  this.loopID = this.getTimer().subscribe(
131
- this.functionToBeRunEachFrame, this.props.duration
160
+ this.functionToBeRunEachFrame,
161
+ this.props.duration
132
162
  );
133
163
  }, this.props.delay);
134
164
  } else {
135
- this.loopID = this.getTimer().subscribe(
136
- this.functionToBeRunEachFrame, this.props.duration
137
- );
165
+ this.loopID = this.getTimer().subscribe(this.functionToBeRunEachFrame, this.props.duration);
138
166
  }
139
167
  } else if (this.props.onEnd) {
140
168
  this.props.onEnd();
@@ -11,17 +11,16 @@ export default class VictoryClipContainer extends React.Component {
11
11
  static displayName = "VictoryClipContainer";
12
12
  static role = "container";
13
13
  static propTypes = {
14
- children: PropTypes.oneOfType([
15
- PropTypes.arrayOf(PropTypes.node),
16
- PropTypes.node
17
- ]),
14
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
18
15
  circleComponent: PropTypes.element,
19
16
  className: PropTypes.string,
20
17
  clipHeight: CustomPropTypes.nonNegative,
21
18
  clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
22
19
  clipPadding: PropTypes.shape({
23
- top: PropTypes.number, bottom: PropTypes.number,
24
- left: PropTypes.number, right: PropTypes.number
20
+ top: PropTypes.number,
21
+ bottom: PropTypes.number,
22
+ left: PropTypes.number,
23
+ right: PropTypes.number
25
24
  }),
26
25
  clipPathComponent: PropTypes.element,
27
26
  clipWidth: CustomPropTypes.nonNegative,
@@ -34,25 +33,23 @@ export default class VictoryClipContainer extends React.Component {
34
33
  transform: PropTypes.string,
35
34
  translateX: PropTypes.number,
36
35
  translateY: PropTypes.number
37
- }
36
+ };
38
37
 
39
38
  static defaultProps = {
40
- circleComponent: <Circle/>,
41
- rectComponent: <Rect/>,
42
- clipPathComponent: <ClipPath/>,
43
- groupComponent: <g/>
44
- }
39
+ circleComponent: <Circle />,
40
+ rectComponent: <Rect />,
41
+ clipPathComponent: <ClipPath />,
42
+ groupComponent: <g />
43
+ };
45
44
 
46
45
  constructor(props) {
47
46
  super(props);
48
- this.clipId = !isObject(props) || props.clipId === undefined ?
49
- uniqueId("victory-clip-") : props.clipId;
47
+ this.clipId =
48
+ !isObject(props) || props.clipId === undefined ? uniqueId("victory-clip-") : props.clipId;
50
49
  }
51
50
 
52
51
  calculateAttributes(props) {
53
- const {
54
- polar, origin, clipWidth = 0, clipHeight = 0, translateX = 0, translateY = 0
55
- } = props;
52
+ const { polar, origin, clipWidth = 0, clipHeight = 0, translateX = 0, translateY = 0 } = props;
56
53
  const clipPadding = Helpers.getPadding({ padding: props.clipPadding });
57
54
  const radius = props.radius || Helpers.getRadius(props);
58
55
  return {
@@ -66,43 +63,59 @@ export default class VictoryClipContainer extends React.Component {
66
63
  renderClippedGroup(props, clipId) {
67
64
  const { style, events, transform, children, className, groupComponent } = props;
68
65
  const clipComponent = this.renderClipComponent(props, clipId);
69
- const groupProps = assign({
70
- className, style, transform, key: `clipped-group-${clipId}`, clipPath: `url(#${clipId})`
71
- }, events);
72
- return React.cloneElement(
73
- groupComponent,
74
- groupProps,
75
- [clipComponent, ...React.Children.toArray(children)]
66
+ const groupProps = assign(
67
+ {
68
+ className,
69
+ style,
70
+ transform,
71
+ key: `clipped-group-${clipId}`,
72
+ clipPath: `url(#${clipId})`
73
+ },
74
+ events
76
75
  );
76
+ return React.cloneElement(groupComponent, groupProps, [
77
+ clipComponent,
78
+ ...React.Children.toArray(children)
79
+ ]);
77
80
  }
78
81
 
79
82
  renderGroup(props) {
80
83
  const { style, events, transform, children, className, groupComponent } = props;
81
84
  return React.cloneElement(
82
- groupComponent, assign({ className, style, transform }, events), children
85
+ groupComponent,
86
+ assign({ className, style, transform }, events),
87
+ children
83
88
  );
84
89
  }
85
90
 
86
91
  renderClipComponent(props, clipId) {
87
92
  const {
88
- polar, origin, clipWidth = 0, clipHeight = 0, translateX = 0, translateY = 0,
89
- circleComponent, rectComponent, clipPathComponent
93
+ polar,
94
+ origin,
95
+ clipWidth = 0,
96
+ clipHeight = 0,
97
+ translateX = 0,
98
+ translateY = 0,
99
+ circleComponent,
100
+ rectComponent,
101
+ clipPathComponent
90
102
  } = props;
91
103
  const { top, bottom, left, right } = Helpers.getPadding({ padding: props.clipPadding });
92
104
  let child;
93
105
  if (polar) {
94
106
  const radius = props.radius || Helpers.getRadius(props);
95
107
  const circleProps = {
96
- r: Math.max((radius + left + right), (radius + top + bottom), 0),
108
+ r: Math.max(radius + left + right, radius + top + bottom, 0),
97
109
  cx: origin.x - left,
98
110
  cy: origin.y - top
99
111
  };
100
112
  child = React.cloneElement(circleComponent, circleProps);
101
113
  } else {
102
114
  const rectProps = {
103
- x: translateX - left, y: translateY - top,
104
- width: Math.max((clipWidth + left + right), 0),
105
- height: Math.max((clipHeight + top + bottom), 0)
115
+ x: translateX - left,
116
+ y: translateY - top,
117
+ width: Math.max(clipWidth + left + right, 0),
118
+ height: Math.max(clipHeight + top + bottom, 0)
106
119
  };
107
120
  child = React.cloneElement(rectComponent, rectProps);
108
121
  }
@@ -10,10 +10,7 @@ export default class VictoryContainer extends React.Component {
10
10
  static displayName = "VictoryContainer";
11
11
  static role = "container";
12
12
  static propTypes = {
13
- children: PropTypes.oneOfType([
14
- PropTypes.arrayOf(PropTypes.node),
15
- PropTypes.node
16
- ]),
13
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
17
14
  className: PropTypes.string,
18
15
  containerId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
19
16
  containerRef: PropTypes.func,
@@ -30,31 +27,33 @@ export default class VictoryContainer extends React.Component {
30
27
  theme: PropTypes.object,
31
28
  title: PropTypes.string,
32
29
  width: CustomPropTypes.nonNegative
33
- }
30
+ };
34
31
 
35
32
  static defaultProps = {
36
33
  className: "VictoryContainer",
37
- portalComponent: <Portal/>,
34
+ portalComponent: <Portal />,
38
35
  portalZIndex: 99,
39
36
  responsive: true
40
- }
37
+ };
41
38
 
42
39
  static contextTypes = {
43
40
  getTimer: PropTypes.func
44
- }
41
+ };
45
42
 
46
43
  static childContextTypes = {
47
44
  portalUpdate: PropTypes.func,
48
45
  portalRegister: PropTypes.func,
49
46
  portalDeregister: PropTypes.func,
50
47
  getTimer: PropTypes.func
51
- }
48
+ };
52
49
 
53
50
  constructor(props) {
54
51
  super(props);
55
52
  this.getTimer = this.getTimer.bind(this);
56
- this.containerId = !isObject(props) || props.containerId === undefined ?
57
- uniqueId("victory-container-") : props.containerId;
53
+ this.containerId =
54
+ !isObject(props) || props.containerId === undefined
55
+ ? uniqueId("victory-container-")
56
+ : props.containerId;
58
57
  this.savePortalRef = (portal) => {
59
58
  this.portalRef = portal;
60
59
  return portal;
@@ -100,20 +99,32 @@ export default class VictoryContainer extends React.Component {
100
99
 
101
100
  renderContainer(props, svgProps, style) {
102
101
  const {
103
- title, desc, portalComponent, className, width, height, portalZIndex, responsive
102
+ title,
103
+ desc,
104
+ portalComponent,
105
+ className,
106
+ width,
107
+ height,
108
+ portalZIndex,
109
+ responsive
104
110
  } = props;
105
111
  const children = this.getChildren(props);
106
112
  const dimensions = responsive ? { width: "100%", height: "100%" } : { width, height };
107
113
  const divStyle = assign(
108
- { pointerEvents: "none", touchAction: "none", position: "relative" }, dimensions
114
+ { pointerEvents: "none", touchAction: "none", position: "relative" },
115
+ dimensions
109
116
  );
110
117
  const portalDivStyle = assign(
111
- { zIndex: portalZIndex, position: "absolute", top: 0, left: 0 }, dimensions
118
+ { zIndex: portalZIndex, position: "absolute", top: 0, left: 0 },
119
+ dimensions
112
120
  );
113
121
  const svgStyle = assign({ pointerEvents: "all" }, dimensions);
114
122
  const portalSvgStyle = assign({ overflow: "visible" }, dimensions);
115
123
  const portalProps = {
116
- width, height, viewBox: svgProps.viewBox, style: portalSvgStyle
124
+ width,
125
+ height,
126
+ viewBox: svgProps.viewBox,
127
+ style: portalSvgStyle
117
128
  };
118
129
  return (
119
130
  <div style={defaults({}, style, divStyle)} className={className} ref={props.containerRef}>
@@ -122,20 +133,23 @@ export default class VictoryContainer extends React.Component {
122
133
  {desc ? <desc id={this.getIdForElement("desc")}>{desc}</desc> : null}
123
134
  {children}
124
135
  </svg>
125
- <div style={portalDivStyle}>
126
- {React.cloneElement(portalComponent, { ...portalProps, ref: this.savePortalRef })}
127
- </div>
136
+ <div style={portalDivStyle}>
137
+ {React.cloneElement(portalComponent, { ...portalProps, ref: this.savePortalRef })}
128
138
  </div>
139
+ </div>
129
140
  );
130
141
  }
131
142
 
132
143
  render() {
133
144
  const { width, height, responsive, events } = this.props;
134
- const style = responsive ?
135
- this.props.style : Helpers.omit(this.props.style, ["height", "width"]);
145
+ const style = responsive
146
+ ? this.props.style
147
+ : Helpers.omit(this.props.style, ["height", "width"]);
136
148
  const svgProps = assign(
137
149
  {
138
- width, height, role: "img",
150
+ width,
151
+ height,
152
+ role: "img",
139
153
  "aria-labelledby": `${this.getIdForElement("title")} ${this.getIdForElement("desc")}`,
140
154
  viewBox: responsive ? `0 0 ${width} ${height}` : undefined
141
155
  },