victory-core 36.9.2 → 37.0.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 (110) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/victory-core.js +4371 -5749
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-accessible-group/victory-accessible-group.js +9 -15
  5. package/es/victory-animation/util.js +28 -47
  6. package/es/victory-animation/victory-animation.js +51 -67
  7. package/es/victory-clip-container/victory-clip-container.js +153 -229
  8. package/es/victory-container/victory-container.js +157 -216
  9. package/es/victory-label/victory-label.js +246 -323
  10. package/es/victory-portal/portal-context.js +1 -2
  11. package/es/victory-portal/portal.js +30 -76
  12. package/es/victory-portal/victory-portal.js +47 -104
  13. package/es/victory-primitives/arc.js +44 -47
  14. package/es/victory-primitives/background.js +14 -17
  15. package/es/victory-primitives/border.js +20 -24
  16. package/es/victory-primitives/circle.js +13 -27
  17. package/es/victory-primitives/clip-path.js +3 -7
  18. package/es/victory-primitives/line-segment.js +20 -24
  19. package/es/victory-primitives/line.js +13 -27
  20. package/es/victory-primitives/path.js +13 -27
  21. package/es/victory-primitives/point.js +36 -40
  22. package/es/victory-primitives/rect.js +13 -27
  23. package/es/victory-primitives/text.js +15 -28
  24. package/es/victory-primitives/tspan.js +13 -26
  25. package/es/victory-primitives/whisker.js +43 -47
  26. package/es/victory-theme/grayscale.js +22 -22
  27. package/es/victory-theme/material.js +46 -46
  28. package/es/victory-theme/victory-theme.js +3 -3
  29. package/es/victory-transition/victory-transition.js +126 -206
  30. package/es/victory-util/add-events.js +263 -374
  31. package/es/victory-util/axis.js +126 -222
  32. package/es/victory-util/collection.js +13 -41
  33. package/es/victory-util/data.js +159 -214
  34. package/es/victory-util/default-transitions.js +33 -51
  35. package/es/victory-util/domain.js +122 -171
  36. package/es/victory-util/events.js +168 -258
  37. package/es/victory-util/helpers.js +153 -178
  38. package/es/victory-util/hooks/use-animation-state.js +61 -99
  39. package/es/victory-util/hooks/use-previous-props.js +2 -2
  40. package/es/victory-util/immutable.js +6 -8
  41. package/es/victory-util/label-helpers.js +128 -130
  42. package/es/victory-util/line-helpers.js +29 -41
  43. package/es/victory-util/log.js +1 -1
  44. package/es/victory-util/point-path-helpers.js +89 -49
  45. package/es/victory-util/scale.js +24 -42
  46. package/es/victory-util/selection.js +39 -40
  47. package/es/victory-util/style.js +8 -13
  48. package/es/victory-util/textsize.js +80 -154
  49. package/es/victory-util/timer-context.js +2 -2
  50. package/es/victory-util/timer.js +40 -76
  51. package/es/victory-util/transitions.js +110 -150
  52. package/es/victory-util/type-helpers.js +2 -3
  53. package/es/victory-util/user-props.js +24 -49
  54. package/es/victory-util/wrapper.js +184 -247
  55. package/lib/index.js +0 -30
  56. package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
  57. package/lib/victory-animation/util.js +28 -63
  58. package/lib/victory-animation/victory-animation.js +54 -83
  59. package/lib/victory-clip-container/victory-clip-container.js +156 -243
  60. package/lib/victory-container/victory-container.js +160 -232
  61. package/lib/victory-label/victory-label.js +248 -344
  62. package/lib/victory-portal/portal-context.js +1 -6
  63. package/lib/victory-portal/portal.js +31 -81
  64. package/lib/victory-portal/victory-portal.js +50 -116
  65. package/lib/victory-primitives/arc.js +48 -57
  66. package/lib/victory-primitives/background.js +16 -28
  67. package/lib/victory-primitives/border.js +22 -34
  68. package/lib/victory-primitives/circle.js +16 -36
  69. package/lib/victory-primitives/clip-path.js +3 -11
  70. package/lib/victory-primitives/index.js +0 -28
  71. package/lib/victory-primitives/line-segment.js +22 -34
  72. package/lib/victory-primitives/line.js +16 -36
  73. package/lib/victory-primitives/path.js +16 -36
  74. package/lib/victory-primitives/point.js +38 -52
  75. package/lib/victory-primitives/rect.js +16 -36
  76. package/lib/victory-primitives/text.js +15 -33
  77. package/lib/victory-primitives/tspan.js +13 -31
  78. package/lib/victory-primitives/whisker.js +45 -57
  79. package/lib/victory-theme/grayscale.js +23 -24
  80. package/lib/victory-theme/material.js +47 -48
  81. package/lib/victory-theme/victory-theme.js +2 -7
  82. package/lib/victory-transition/victory-transition.js +129 -224
  83. package/lib/victory-util/add-events.js +263 -380
  84. package/lib/victory-util/axis.js +128 -241
  85. package/lib/victory-util/collection.js +13 -50
  86. package/lib/victory-util/data.js +160 -239
  87. package/lib/victory-util/default-transitions.js +33 -54
  88. package/lib/victory-util/domain.js +123 -193
  89. package/lib/victory-util/events.js +167 -274
  90. package/lib/victory-util/helpers.js +156 -207
  91. package/lib/victory-util/hooks/index.js +0 -2
  92. package/lib/victory-util/hooks/use-animation-state.js +63 -113
  93. package/lib/victory-util/hooks/use-previous-props.js +2 -7
  94. package/lib/victory-util/immutable.js +6 -18
  95. package/lib/victory-util/index.js +2 -51
  96. package/lib/victory-util/label-helpers.js +130 -141
  97. package/lib/victory-util/line-helpers.js +31 -49
  98. package/lib/victory-util/log.js +1 -2
  99. package/lib/victory-util/point-path-helpers.js +91 -63
  100. package/lib/victory-util/scale.js +26 -57
  101. package/lib/victory-util/selection.js +41 -49
  102. package/lib/victory-util/style.js +8 -16
  103. package/lib/victory-util/textsize.js +80 -157
  104. package/lib/victory-util/timer-context.js +2 -8
  105. package/lib/victory-util/timer.js +40 -76
  106. package/lib/victory-util/transitions.js +110 -152
  107. package/lib/victory-util/type-helpers.js +2 -9
  108. package/lib/victory-util/user-props.js +25 -59
  109. package/lib/victory-util/wrapper.js +186 -281
  110. package/package.json +2 -2
@@ -1,62 +1,50 @@
1
1
  import * as d3Shape from "victory-vendor/d3-shape";
2
-
3
- var defined = function (d) {
4
- var y = d._y1 !== undefined ? d._y1 : d._y;
2
+ const defined = d => {
3
+ const y = d._y1 !== undefined ? d._y1 : d._y;
5
4
  return y !== null && y !== undefined && d._y0 !== null;
6
5
  };
7
-
8
- var getXAccessor = function (scale) {
9
- return function (d) {
10
- return scale.x(d._x1 !== undefined ? d._x1 : d._x);
11
- };
6
+ const getXAccessor = scale => {
7
+ return d => scale.x(d._x1 !== undefined ? d._x1 : d._x);
12
8
  };
13
-
14
- var getYAccessor = function (scale) {
15
- return function (d) {
16
- return scale.y(d._y1 !== undefined ? d._y1 : d._y);
17
- };
9
+ const getYAccessor = scale => {
10
+ return d => scale.y(d._y1 !== undefined ? d._y1 : d._y);
18
11
  };
19
-
20
- var getAngleAccessor = function (scale) {
21
- return function (d) {
22
- var x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
12
+ const getAngleAccessor = scale => {
13
+ return d => {
14
+ const x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
23
15
  return -1 * x + Math.PI / 2;
24
16
  };
25
17
  };
26
-
27
- var toNewName = function (interpolation) {
18
+ const toNewName = interpolation => {
28
19
  // d3 shape changed the naming scheme for interpolators from "basis" -> "curveBasis" etc.
29
- var capitalize = function (s) {
30
- return s && s[0].toUpperCase() + s.slice(1);
31
- };
32
-
33
- return "curve".concat(capitalize(interpolation));
20
+ const capitalize = s => s && s[0].toUpperCase() + s.slice(1);
21
+ return `curve${capitalize(interpolation)}`;
34
22
  };
35
-
36
- var toNewNameClosed = function (interpolation) {
37
- return "".concat(toNewName(interpolation), "Closed");
23
+ const toNewNameClosed = interpolation => {
24
+ return `${toNewName(interpolation)}Closed`;
38
25
  };
39
-
40
- export var getInterpolationFunction = function (props) {
41
- var interpolation = props.interpolation;
42
-
26
+ export const getInterpolationFunction = props => {
27
+ const {
28
+ interpolation
29
+ } = props;
43
30
  if (typeof interpolation === "function") {
44
31
  return interpolation;
45
32
  }
46
-
47
33
  if (typeof interpolation === "string") {
48
- var polar = props.polar,
49
- _props$openCurve = props.openCurve,
50
- openCurve = _props$openCurve === void 0 ? !polar : _props$openCurve;
51
- var interpolationName = !openCurve ? toNewNameClosed(interpolation) : toNewName(interpolation);
34
+ const {
35
+ polar,
36
+ openCurve = !polar
37
+ } = props;
38
+ const interpolationName = !openCurve ? toNewNameClosed(interpolation) : toNewName(interpolation);
52
39
  return d3Shape[interpolationName];
53
40
  }
54
-
55
41
  return d3Shape.curveLinear;
56
42
  };
57
- export var getLineFunction = function (props) {
58
- var polar = props.polar,
59
- scale = props.scale,
60
- horizontal = props.horizontal;
43
+ export const getLineFunction = props => {
44
+ const {
45
+ polar,
46
+ scale,
47
+ horizontal
48
+ } = props;
61
49
  return polar ? d3Shape.lineRadial().defined(defined).curve(getInterpolationFunction(props)).angle(getAngleAccessor(scale)).radius(getYAccessor(scale)) : d3Shape.line().defined(defined).curve(getInterpolationFunction(props)).x(horizontal ? getYAccessor(scale) : getXAccessor(scale)).y(horizontal ? getXAccessor(scale) : getYAccessor(scale));
62
50
  };
@@ -1,6 +1,6 @@
1
1
  /* global console */
2
-
3
2
  /* eslint-disable no-console */
3
+
4
4
  // TODO: Use "warning" npm module like React is switching to.
5
5
  export function warn(message) {
6
6
  if (process.env.NODE_ENV !== "production") {
@@ -1,71 +1,111 @@
1
1
  /* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 2.5, 3] }]*/
2
+
2
3
  import * as Helpers from "./helpers";
3
4
  export function circle(x, y, size) {
4
- return "M ".concat(x, ", ").concat(y, "\n m ").concat(-size, ", 0\n a ").concat(size, ", ").concat(size, " 0 1,0 ").concat(size * 2, ",0\n a ").concat(size, ", ").concat(size, " 0 1,0 ").concat(-size * 2, ",0");
5
+ return `M ${x}, ${y}
6
+ m ${-size}, 0
7
+ a ${size}, ${size} 0 1,0 ${size * 2},0
8
+ a ${size}, ${size} 0 1,0 ${-size * 2},0`;
5
9
  }
6
10
  export function square(x, y, size) {
7
- var baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
8
-
9
- var x0 = x - baseSize;
10
- var y1 = y + baseSize;
11
- var distance = x + baseSize - x0;
12
- return "M ".concat(x0, ", ").concat(y1, "\n h").concat(distance, "\n v-").concat(distance, "\n h-").concat(distance, "\n z");
11
+ const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
12
+ const x0 = x - baseSize;
13
+ const y1 = y + baseSize;
14
+ const distance = x + baseSize - x0;
15
+ return `M ${x0}, ${y1}
16
+ h${distance}
17
+ v-${distance}
18
+ h-${distance}
19
+ z`;
13
20
  }
14
21
  export function diamond(x, y, size) {
15
- var baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
16
-
17
- var length = Math.sqrt(2 * (baseSize * baseSize));
18
- return "M ".concat(x, ", ").concat(y + length, "\n l ").concat(length, ", -").concat(length, "\n l -").concat(length, ", -").concat(length, "\n l -").concat(length, ", ").concat(length, "\n l ").concat(length, ", ").concat(length, "\n z");
22
+ const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
23
+ const length = Math.sqrt(2 * (baseSize * baseSize));
24
+ return `M ${x}, ${y + length}
25
+ l ${length}, -${length}
26
+ l -${length}, -${length}
27
+ l -${length}, ${length}
28
+ l ${length}, ${length}
29
+ z`;
19
30
  }
20
31
  export function triangleDown(x, y, size) {
21
- var height = size / 2 * Math.sqrt(3);
22
- var x0 = x - size;
23
- var x1 = x + size;
24
- var y0 = y - size;
25
- var y1 = y + height;
26
- return "M ".concat(x0, ", ").concat(y0, "\n L ").concat(x1, ", ").concat(y0, "\n L ").concat(x, ", ").concat(y1, "\n z");
32
+ const height = size / 2 * Math.sqrt(3);
33
+ const x0 = x - size;
34
+ const x1 = x + size;
35
+ const y0 = y - size;
36
+ const y1 = y + height;
37
+ return `M ${x0}, ${y0}
38
+ L ${x1}, ${y0}
39
+ L ${x}, ${y1}
40
+ z`;
27
41
  }
28
42
  export function triangleUp(x, y, size) {
29
- var height = size / 2 * Math.sqrt(3);
30
- var x0 = x - size;
31
- var x1 = x + size;
32
- var y0 = y - height;
33
- var y1 = y + size;
34
- return "M ".concat(x0, ", ").concat(y1, "\n L ").concat(x1, ", ").concat(y1, "\n L ").concat(x, ", ").concat(y0, "\n z");
43
+ const height = size / 2 * Math.sqrt(3);
44
+ const x0 = x - size;
45
+ const x1 = x + size;
46
+ const y0 = y - height;
47
+ const y1 = y + size;
48
+ return `M ${x0}, ${y1}
49
+ L ${x1}, ${y1}
50
+ L ${x}, ${y0}
51
+ z`;
35
52
  }
36
53
  export function plus(x, y, size) {
37
- var baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
38
-
39
- var distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
40
-
41
- return "\n M ".concat(x - distance / 2, ", ").concat(y + baseSize, "\n v-").concat(distance, "\n h-").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h-").concat(distance, "\n v").concat(distance, "\n z");
54
+ const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
55
+ const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
56
+ return `
57
+ M ${x - distance / 2}, ${y + baseSize}
58
+ v-${distance}
59
+ h-${distance}
60
+ v-${distance}
61
+ h${distance}
62
+ v-${distance}
63
+ h${distance}
64
+ v${distance}
65
+ h${distance}
66
+ v${distance}
67
+ h-${distance}
68
+ v${distance}
69
+ z`;
42
70
  }
43
71
  export function cross(x, y, size) {
44
- var baseSize = 0.8 * size; // eslint-disable-line no-magic-numbers
45
-
46
- var distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
47
-
48
- return "\n M ".concat(x - distance / 2, ", ").concat(y + baseSize + distance, "\n v-").concat(distance * 2, "\n h-").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h-").concat(distance, "\n v").concat(distance * 2, "\n z");
72
+ const baseSize = 0.8 * size; // eslint-disable-line no-magic-numbers
73
+ const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
74
+ return `
75
+ M ${x - distance / 2}, ${y + baseSize + distance}
76
+ v-${distance * 2}
77
+ h-${distance}
78
+ v-${distance}
79
+ h${distance}
80
+ v-${distance}
81
+ h${distance}
82
+ v${distance}
83
+ h${distance}
84
+ v${distance}
85
+ h-${distance}
86
+ v${distance * 2}
87
+ z`;
49
88
  }
50
89
  export function minus(x, y, size) {
51
- var baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
52
-
53
- var lineHeight = baseSize - baseSize * 0.3; // eslint-disable-line no-magic-numbers
54
-
55
- var x0 = x - baseSize;
56
- var y1 = y + lineHeight / 2;
57
- var distance = x + baseSize - x0;
58
- return "M ".concat(x0, ", ").concat(y1, "\n h").concat(distance, "\n v-").concat(lineHeight, "\n h-").concat(distance, "\n z");
90
+ const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
91
+ const lineHeight = baseSize - baseSize * 0.3; // eslint-disable-line no-magic-numbers
92
+ const x0 = x - baseSize;
93
+ const y1 = y + lineHeight / 2;
94
+ const distance = x + baseSize - x0;
95
+ return `M ${x0}, ${y1}
96
+ h${distance}
97
+ v-${lineHeight}
98
+ h-${distance}
99
+ z`;
59
100
  }
60
101
  export function star(x, y, size) {
61
- var baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
62
-
63
- var angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
102
+ const baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
103
+ const angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
64
104
  // eslint-disable-next-line no-magic-numbers
65
-
66
- var starCoords = Helpers.range(10).map(function (index) {
67
- var length = index % 2 === 0 ? baseSize : baseSize / 2;
68
- return "".concat(length * Math.sin(angle * (index + 1)) + x, ",\n ").concat(length * Math.cos(angle * (index + 1)) + y);
105
+ const starCoords = Helpers.range(10).map(index => {
106
+ const length = index % 2 === 0 ? baseSize : baseSize / 2;
107
+ return `${length * Math.sin(angle * (index + 1)) + x},
108
+ ${length * Math.cos(angle * (index + 1)) + y}`;
69
109
  });
70
- return "M ".concat(starCoords.join("L"), " z");
110
+ return `M ${starCoords.join("L")} z`;
71
111
  }
@@ -1,95 +1,79 @@
1
1
  import _isPlainObject from "lodash/isPlainObject";
2
+ /* eslint-disable no-use-before-define */
2
3
  import * as Helpers from "./helpers";
3
4
  import * as Collection from "./collection";
4
5
  import * as d3Scale from "victory-vendor/d3-scale";
5
- var supportedScaleStrings = ["linear", "time", "log", "sqrt"];
6
-
6
+ const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
7
7
  // Private Functions
8
+
8
9
  function toNewName(scale) {
9
10
  // d3 scale changed the naming scheme for scale from "linear" -> "scaleLinear" etc.
10
- var capitalize = function (s) {
11
- return s && s[0].toUpperCase() + s.slice(1);
12
- };
13
-
14
- return "scale".concat(capitalize(scale));
11
+ const capitalize = s => s && s[0].toUpperCase() + s.slice(1);
12
+ return `scale${capitalize(scale)}`;
15
13
  }
16
-
17
14
  export function validScale(scale) {
18
15
  if (typeof scale === "function") {
19
16
  return Helpers.isFunction(scale.copy) && Helpers.isFunction(scale.domain) && Helpers.isFunction(scale.range);
20
17
  } else if (typeof scale === "string") {
21
18
  return supportedScaleStrings.includes(scale);
22
19
  }
23
-
24
20
  return false;
25
21
  }
26
-
27
22
  function isScaleDefined(props, axis) {
28
23
  if (!props.scale) {
29
24
  return false;
30
25
  } else if (props.scale.x || props.scale.y) {
31
26
  return !!props.scale[axis];
32
27
  }
33
-
34
28
  return true;
35
29
  }
36
-
37
30
  function getScaleTypeFromProps(props, axis) {
38
31
  if (!isScaleDefined(props, axis)) {
39
32
  return undefined;
40
33
  }
41
-
42
- var scale = props.scale[axis] || props.scale;
34
+ const scale = props.scale[axis] || props.scale;
43
35
  return typeof scale === "string" ? scale : getType(scale);
44
36
  }
45
-
46
37
  function getScaleFromDomain(props, axis) {
47
- var domain;
48
-
38
+ let domain;
49
39
  if (props.domain && props.domain[axis]) {
50
40
  domain = props.domain[axis];
51
41
  } else if (props.domain && Array.isArray(props.domain)) {
52
42
  domain = props.domain;
53
43
  }
54
-
55
44
  if (!domain) {
56
45
  return undefined;
57
46
  }
58
-
59
47
  return Collection.containsDates(domain) ? "time" : "linear";
60
48
  }
61
-
62
49
  function getScaleTypeFromData(props, axis) {
63
50
  if (!props.data) {
64
51
  return "linear";
65
52
  }
66
-
67
- var accessor = Helpers.createAccessor(props[axis]);
68
- var axisData = props.data.map(function (datum) {
69
- var processedData = _isPlainObject(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
53
+ const accessor = Helpers.createAccessor(props[axis]);
54
+ const axisData = props.data.map(datum => {
55
+ const processedData = _isPlainObject(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
70
56
  return processedData !== undefined ? processedData : datum[axis];
71
57
  });
72
58
  return Collection.containsDates(axisData) ? "time" : "linear";
73
- } // Exported Functions
59
+ }
74
60
 
61
+ // Exported Functions
75
62
 
76
63
  export function getScaleFromName(name) {
77
64
  if (validScale(name)) {
78
- var methodName = toNewName(name); // @ts-expect-error scaleTime is not directly compatible with our D3Scale definition
79
-
65
+ const methodName = toNewName(name);
66
+ // @ts-expect-error scaleTime is not directly compatible with our D3Scale definition
80
67
  return d3Scale[methodName]();
81
68
  }
82
-
83
69
  return d3Scale.scaleLinear();
84
70
  }
85
71
  export function getBaseScale(props, axis) {
86
- var scale = getScaleFromProps(props, axis);
87
-
72
+ const scale = getScaleFromProps(props, axis);
88
73
  if (scale) {
89
74
  return typeof scale === "string" ? getScaleFromName(scale) : scale;
90
75
  }
91
-
92
- var defaultScale = getScaleFromDomain(props, axis) || getScaleTypeFromData(props, axis);
76
+ const defaultScale = getScaleFromDomain(props, axis) || getScaleTypeFromData(props, axis);
93
77
  return getScaleFromName(defaultScale);
94
78
  }
95
79
  export function getDefaultScale() {
@@ -99,28 +83,27 @@ export function getScaleFromProps(props, axis) {
99
83
  if (!isScaleDefined(props, axis)) {
100
84
  return undefined;
101
85
  }
102
-
103
- var scale = props.scale[axis] || props.scale;
104
-
86
+ const scale = props.scale[axis] || props.scale;
105
87
  if (validScale(scale)) {
106
88
  return Helpers.isFunction(scale) ? scale : getScaleFromName(scale);
107
89
  }
108
-
109
90
  return undefined;
110
91
  }
111
92
  export function getScaleType(props, axis) {
112
93
  // if the scale was not given in props, it will be set to linear or time depending on data
113
94
  return getScaleTypeFromProps(props, axis) || getScaleTypeFromData(props, axis);
114
- } // Ordered type inference off of function fields.
115
- // **Note**: Brittle because reliant on d3 internals.
95
+ }
116
96
 
117
- var DUCK_TYPES = [{
97
+ // Ordered type inference off of function fields.
98
+ // **Note**: Brittle because reliant on d3 internals.
99
+ const DUCK_TYPES = [{
118
100
  name: "quantile",
119
101
  method: "quantiles"
120
102
  }, {
121
103
  name: "log",
122
104
  method: "base"
123
- } // TODO(2214): Re-evaluate (1) duck typing approach, and (2) if duck typing,
105
+ }
106
+ // TODO(2214): Re-evaluate (1) duck typing approach, and (2) if duck typing,
124
107
  // do we need a different approach? (Multiple keys? Stringifying functions?)
125
108
  // https://github.com/FormidableLabs/victory/issues/2214
126
109
  // Below are matches that don't seem to otherwise occur in Victory code base.
@@ -132,8 +115,7 @@ export function getType(scale) {
132
115
  if (typeof scale === "string") {
133
116
  return scale;
134
117
  }
135
-
136
- var scaleType = DUCK_TYPES.filter(function (type) {
118
+ const scaleType = DUCK_TYPES.filter(type => {
137
119
  return scale[type.method] !== undefined;
138
120
  })[0];
139
121
  return scaleType ? scaleType.name : undefined;
@@ -1,41 +1,38 @@
1
1
  import * as Collection from "./collection";
2
-
3
2
  // Private Functions
3
+
4
4
  function transformTarget(target, matrix, dimension) {
5
- var a = matrix.a,
6
- d = matrix.d,
7
- e = matrix.e,
8
- f = matrix.f;
5
+ const {
6
+ a,
7
+ d,
8
+ e,
9
+ f
10
+ } = matrix;
9
11
  return dimension === "y" ? d * target + f : a * target + e;
10
12
  }
11
-
12
13
  function getTransformationMatrix(svg) {
13
14
  return svg.getScreenCTM().inverse();
14
15
  }
15
-
16
16
  function isNativeTouchEvent(nativeEvent) {
17
17
  return !!(nativeEvent && nativeEvent.identifier !== undefined);
18
18
  }
19
-
20
19
  function isReactTouchEvent(evt) {
21
20
  return evt.changedTouches && evt.changedTouches.length > 0;
22
- } // Exported Functions
21
+ }
23
22
 
23
+ // Exported Functions
24
24
 
25
25
  export function getParentSVG(evt) {
26
26
  if (isNativeTouchEvent(evt.nativeEvent)) {
27
27
  // @ts-expect-error Seems like a superfluous check.
28
28
  return undefined;
29
29
  }
30
-
31
- var getParent = function (target) {
30
+ const getParent = target => {
32
31
  if (target.nodeName === "svg") {
33
32
  return target;
34
33
  }
35
-
36
34
  return target.parentNode ? getParent(target.parentNode) : target;
37
35
  };
38
-
39
36
  return getParent(evt.target);
40
37
  }
41
38
  export function getSVGEventCoordinates(evt, svg) {
@@ -47,19 +44,20 @@ export function getSVGEventCoordinates(evt, svg) {
47
44
  y: evt.nativeEvent.locationY
48
45
  };
49
46
  }
50
-
51
- var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
52
- var matrix = getTransformationMatrix(svg || getParentSVG(location));
47
+ const location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
48
+ const matrix = getTransformationMatrix(svg || getParentSVG(location));
53
49
  return {
54
50
  x: transformTarget(location.clientX, matrix, "x"),
55
51
  y: transformTarget(location.clientY, matrix, "y")
56
52
  };
57
53
  }
58
54
  export function getDomainCoordinates(props, domain) {
59
- var horizontal = props.horizontal;
60
- var scale = props.scale; // FIXME: add support for DomainTuple: [number, number]
61
-
62
- var domainObj = domain || {
55
+ const {
56
+ horizontal
57
+ } = props;
58
+ const scale = props.scale;
59
+ // FIXME: add support for DomainTuple: [number, number]
60
+ const domainObj = domain || {
63
61
  x: scale.x.domain(),
64
62
  y: scale.y.domain()
65
63
  };
@@ -67,45 +65,46 @@ export function getDomainCoordinates(props, domain) {
67
65
  x: horizontal ? [scale.y(domainObj.y[0]), scale.y(domainObj.y[1])] : [scale.x(domainObj.x[0]), scale.x(domainObj.x[1])],
68
66
  y: horizontal ? [scale.x(domainObj.x[0]), scale.x(domainObj.x[1])] : [scale.y(domainObj.y[0]), scale.y(domainObj.y[1])]
69
67
  };
70
- } // eslint-disable-next-line max-params
68
+ }
71
69
 
70
+ // eslint-disable-next-line max-params
72
71
  export function getDataCoordinates(props, scale, x, y) {
73
- var polar = props.polar,
74
- horizontal = props.horizontal;
75
-
72
+ const {
73
+ polar,
74
+ horizontal
75
+ } = props;
76
76
  if (!polar) {
77
77
  return {
78
78
  x: horizontal ? scale.x.invert(y) : scale.x.invert(x),
79
79
  y: horizontal ? scale.y.invert(x) : scale.y.invert(y)
80
80
  };
81
81
  }
82
-
83
- var origin = props.origin || {
82
+ const origin = props.origin || {
84
83
  x: 0,
85
84
  y: 0
86
85
  };
87
- var baseX = x - origin.x;
88
- var baseY = y - origin.y;
89
- var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
90
- var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
86
+ const baseX = x - origin.x;
87
+ const baseY = y - origin.y;
88
+ const radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
89
+ const angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
91
90
  return {
92
91
  x: scale.x.invert(angle),
93
92
  y: scale.y.invert(radius)
94
93
  };
95
94
  }
96
95
  export function getBounds(props) {
97
- var x1 = props.x1,
98
- x2 = props.x2,
99
- y1 = props.y1,
100
- y2 = props.y2,
101
- scale = props.scale;
102
- var point1 = getDataCoordinates(props, scale, x1, y1);
103
- var point2 = getDataCoordinates(props, scale, x2, y2);
104
-
105
- var makeBound = function (a, b) {
96
+ const {
97
+ x1,
98
+ x2,
99
+ y1,
100
+ y2,
101
+ scale
102
+ } = props;
103
+ const point1 = getDataCoordinates(props, scale, x1, y1);
104
+ const point2 = getDataCoordinates(props, scale, x2, y2);
105
+ const makeBound = (a, b) => {
106
106
  return [Collection.getMinValue([a, b]), Collection.getMaxValue([a, b])];
107
107
  };
108
-
109
108
  return {
110
109
  x: makeBound(point1.x, point2.x),
111
110
  y: makeBound(point1.y, point2.y)
@@ -7,32 +7,28 @@
7
7
  * @param {Object} obj An object of transform definitions.
8
8
  * @returns {String} The generated transform string.
9
9
  */
10
- export var toTransformString = function (obj) {
10
+ export const toTransformString = function (obj) {
11
11
  for (var _len = arguments.length, more = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12
12
  more[_key - 1] = arguments[_key];
13
13
  }
14
-
15
14
  if (more.length > 0) {
16
- return more.reduce(function (memo, currentObj) {
15
+ return more.reduce((memo, currentObj) => {
17
16
  return [memo, toTransformString(currentObj)].join(" ");
18
17
  }, toTransformString(obj)).trim();
19
18
  }
20
-
21
19
  if (obj === undefined || obj === null || typeof obj === "string") {
22
20
  return obj;
23
21
  }
24
-
25
- var transforms = [];
26
-
27
- for (var key in obj) {
22
+ const transforms = [];
23
+ for (const key in obj) {
28
24
  if (obj.hasOwnProperty(key)) {
29
- var value = obj[key];
30
- transforms.push("".concat(key, "(").concat(value, ")"));
25
+ const value = obj[key];
26
+ transforms.push(`${key}(${value})`);
31
27
  }
32
28
  }
33
-
34
29
  return transforms.join(" ").trim();
35
30
  };
31
+
36
32
  /**
37
33
  * Given the name of a color scale, getColorScale will return an array
38
34
  * of 5 hex string values in that color scale. If no 'name' parameter
@@ -40,9 +36,8 @@ export var toTransformString = function (obj) {
40
36
  * @param {String} name The name of the color scale to return (optional).
41
37
  * @returns {Array} An array of 5 hex string values composing a color scale.
42
38
  */
43
-
44
39
  export function getColorScale(name) {
45
- var scales = {
40
+ const scales = {
46
41
  grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
47
42
  qualitative: ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"],
48
43
  heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],