plottable 3.13.0 → 4.1.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 (140) hide show
  1. package/README.md +9 -2
  2. package/build/src/animators/easingAnimator.d.ts +2 -2
  3. package/build/src/animators/easingAnimator.js +1 -1
  4. package/build/src/animators/index.js +2 -2
  5. package/build/src/axes/axis.d.ts +1 -1
  6. package/build/src/axes/axis.js +5 -5
  7. package/build/src/axes/categoryAxis.js +8 -7
  8. package/build/src/axes/index.js +3 -3
  9. package/build/src/axes/numericAxis.js +1 -1
  10. package/build/src/axes/timeAxis.d.ts +5 -5
  11. package/build/src/axes/timeAxis.js +6 -6
  12. package/build/src/components/component.d.ts +4 -4
  13. package/build/src/components/component.js +4 -4
  14. package/build/src/components/componentContainer.js +1 -1
  15. package/build/src/components/dragBoxLayer.d.ts +1 -1
  16. package/build/src/components/dragBoxLayer.js +1 -1
  17. package/build/src/components/dragLineLayer.js +1 -1
  18. package/build/src/components/gridlines.js +1 -1
  19. package/build/src/components/group.js +1 -1
  20. package/build/src/components/guideLineLayer.js +1 -1
  21. package/build/src/components/index.js +14 -14
  22. package/build/src/components/interpolatedColorLegend.js +1 -1
  23. package/build/src/components/label.d.ts +1 -1
  24. package/build/src/components/label.js +3 -3
  25. package/build/src/components/legend.js +17 -9
  26. package/build/src/components/plotGroup.js +1 -1
  27. package/build/src/components/selectionBoxLayer.js +2 -2
  28. package/build/src/components/table.js +1 -1
  29. package/build/src/components/wrappedLabel.js +1 -1
  30. package/build/src/components/xDragBoxLayer.js +1 -1
  31. package/build/src/components/yDragBoxLayer.js +1 -1
  32. package/build/src/core/dataset.d.ts +1 -1
  33. package/build/src/core/formatters.d.ts +2 -2
  34. package/build/src/core/formatters.js +16 -13
  35. package/build/src/core/interfaces.d.ts +9 -9
  36. package/build/src/core/renderController.d.ts +1 -1
  37. package/build/src/core/renderController.js +6 -6
  38. package/build/src/core/symbolFactories.d.ts +2 -2
  39. package/build/src/core/symbolFactories.js +15 -15
  40. package/build/src/core/version.js +1 -1
  41. package/build/src/dispatchers/dispatcher.js +8 -1
  42. package/build/src/dispatchers/index.js +3 -3
  43. package/build/src/dispatchers/keyDispatcher.d.ts +1 -1
  44. package/build/src/dispatchers/keyDispatcher.js +1 -1
  45. package/build/src/dispatchers/mouseDispatcher.d.ts +1 -1
  46. package/build/src/dispatchers/mouseDispatcher.js +1 -1
  47. package/build/src/dispatchers/touchDispatcher.d.ts +1 -1
  48. package/build/src/dispatchers/touchDispatcher.js +1 -1
  49. package/build/src/drawers/arcDrawer.js +1 -1
  50. package/build/src/drawers/arcOutlineDrawer.js +1 -1
  51. package/build/src/drawers/areaDrawer.js +3 -3
  52. package/build/src/drawers/canvasBuffer.js +2 -2
  53. package/build/src/drawers/canvasDrawer.d.ts +1 -1
  54. package/build/src/drawers/canvasDrawer.js +8 -8
  55. package/build/src/drawers/drawStep.d.ts +2 -2
  56. package/build/src/drawers/index.js +11 -11
  57. package/build/src/drawers/lineDrawer.js +3 -3
  58. package/build/src/drawers/rectangleDrawer.js +2 -2
  59. package/build/src/drawers/segmentDrawer.js +1 -1
  60. package/build/src/drawers/symbolDrawer.js +3 -3
  61. package/build/src/index.js +14 -14
  62. package/build/src/interactions/clickInteraction.d.ts +1 -1
  63. package/build/src/interactions/clickInteraction.js +8 -1
  64. package/build/src/interactions/dragInteraction.d.ts +2 -2
  65. package/build/src/interactions/dragInteraction.js +7 -1
  66. package/build/src/interactions/index.js +5 -5
  67. package/build/src/interactions/interaction.d.ts +2 -1
  68. package/build/src/interactions/interaction.js +11 -1
  69. package/build/src/interactions/keyInteraction.d.ts +1 -1
  70. package/build/src/interactions/keyInteraction.js +8 -1
  71. package/build/src/interactions/panZoomConstraints.js +5 -6
  72. package/build/src/interactions/panZoomInteraction.d.ts +4 -4
  73. package/build/src/interactions/panZoomInteraction.js +15 -10
  74. package/build/src/interactions/pointerInteraction.d.ts +1 -1
  75. package/build/src/interactions/pointerInteraction.js +8 -1
  76. package/build/src/memoize/index.js +3 -3
  77. package/build/src/memoize/memThunk.d.ts +1 -1
  78. package/build/src/memoize/memThunk.js +1 -2
  79. package/build/src/memoize/memoize.d.ts +1 -1
  80. package/build/src/memoize/memoize.js +1 -2
  81. package/build/src/memoize/memoizeProjectors.js +2 -3
  82. package/build/src/memoize/signature.d.ts +1 -1
  83. package/build/src/memoize/signature.js +10 -10
  84. package/build/src/plots/areaPlot.js +4 -3
  85. package/build/src/plots/barPlot.d.ts +9 -3
  86. package/build/src/plots/barPlot.js +18 -6
  87. package/build/src/plots/clusteredBarPlot.js +1 -1
  88. package/build/src/plots/commons.js +1 -1
  89. package/build/src/plots/index.js +12 -12
  90. package/build/src/plots/linePlot.d.ts +2 -3
  91. package/build/src/plots/linePlot.js +3 -2
  92. package/build/src/plots/piePlot.js +4 -2
  93. package/build/src/plots/plot.d.ts +4 -2
  94. package/build/src/plots/plot.js +12 -10
  95. package/build/src/plots/rectanglePlot.d.ts +5 -0
  96. package/build/src/plots/rectanglePlot.js +14 -4
  97. package/build/src/plots/scatterPlot.d.ts +11 -0
  98. package/build/src/plots/scatterPlot.js +31 -4
  99. package/build/src/plots/segmentPlot.js +1 -1
  100. package/build/src/plots/stackedAreaPlot.js +5 -6
  101. package/build/src/plots/stackedBarPlot.js +4 -4
  102. package/build/src/plots/waterfallPlot.js +1 -1
  103. package/build/src/plots/xyPlot.js +4 -3
  104. package/build/src/scales/categoryScale.d.ts +1 -0
  105. package/build/src/scales/categoryScale.js +9 -6
  106. package/build/src/scales/colorScale.d.ts +4 -3
  107. package/build/src/scales/colorScale.js +50 -57
  108. package/build/src/scales/index.js +9 -9
  109. package/build/src/scales/interpolatedColorScale.js +11 -10
  110. package/build/src/scales/linearScale.js +3 -3
  111. package/build/src/scales/logScale.js +3 -3
  112. package/build/src/scales/modifiedLogScale.js +2 -2
  113. package/build/src/scales/quantitativeScale.js +1 -1
  114. package/build/src/scales/scale.d.ts +1 -1
  115. package/build/src/scales/tickGenerators.js +2 -3
  116. package/build/src/scales/timeScale.js +4 -4
  117. package/build/src/utils/arrayUtils.js +5 -7
  118. package/build/src/utils/callbackSet.js +1 -1
  119. package/build/src/utils/coerceD3.js +1 -2
  120. package/build/src/utils/colorUtils.js +3 -4
  121. package/build/src/utils/d3ShapeUtils.d.ts +11 -0
  122. package/build/src/utils/d3ShapeUtils.js +17 -0
  123. package/build/src/utils/domUtils.js +20 -20
  124. package/build/src/utils/entityStore.d.ts +6 -3
  125. package/build/src/utils/index.js +8 -8
  126. package/build/src/utils/makeEnum.js +1 -2
  127. package/build/src/utils/mathUtils.d.ts +2 -2
  128. package/build/src/utils/mathUtils.js +17 -18
  129. package/build/src/utils/objectUtils.js +1 -2
  130. package/build/src/utils/rTree.d.ts +12 -3
  131. package/build/src/utils/rTree.js +19 -7
  132. package/build/src/utils/rTreeSplitStrategies.d.ts +1 -1
  133. package/build/src/utils/stackingUtils.d.ts +6 -6
  134. package/build/src/utils/stackingUtils.js +40 -7
  135. package/build/src/utils/transformAwareTranslator.js +2 -2
  136. package/build/src/utils/windowUtils.js +4 -5
  137. package/package.json +15 -14
  138. package/plottable.css +4 -3
  139. package/plottable.js +18083 -18287
  140. package/plottable.js.map +1 -1
@@ -4,7 +4,9 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.colorTest = exports.lightenColor = exports.contrast = void 0;
7
+ exports.contrast = contrast;
8
+ exports.lightenColor = lightenColor;
9
+ exports.colorTest = colorTest;
8
10
  var d3 = require("d3");
9
11
  var nativeMath = window.Math;
10
12
  /**
@@ -19,7 +21,6 @@ function contrast(a, b) {
19
21
  var l2 = luminance(b) + 0.05;
20
22
  return l1 > l2 ? l1 / l2 : l2 / l1;
21
23
  }
22
- exports.contrast = contrast;
23
24
  /**
24
25
  * Returns a brighter copy of this color. Each channel is multiplied by 0.7 ^ -factor.
25
26
  * Channel values are capped at the maximum value of 255, and the minimum value of 30.
@@ -28,7 +29,6 @@ function lightenColor(color, factor) {
28
29
  var brightened = d3.color(color).brighter(factor);
29
30
  return brightened.rgb().toString();
30
31
  }
31
- exports.lightenColor = lightenColor;
32
32
  /**
33
33
  * Gets the Hex Code of the color resulting by applying the className CSS class to the
34
34
  * colorTester selection. Returns null if the tester is transparent.
@@ -62,7 +62,6 @@ function colorTest(colorTester, className) {
62
62
  colorTester.classed(className, false);
63
63
  return hexCode;
64
64
  }
65
- exports.colorTest = colorTest;
66
65
  /**
67
66
  * Return relative luminance (defined here: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef)
68
67
  * Based on implementation from chroma.js by Gregor Aisch (gka) (licensed under BSD)
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright 2014-present Palantir Technologies
3
+ * @license MIT
4
+ */
5
+ /**
6
+ * Preserve full-precision SVG paths with d3-shape 3.2+, which rounds by default.
7
+ * Earlier versions have no digits() method and already use full precision.
8
+ */
9
+ export declare function withFullPrecision<T extends {
10
+ digits?: (digits: number | null) => unknown;
11
+ }>(generator: T): T;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2014-present Palantir Technologies
4
+ * @license MIT
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.withFullPrecision = withFullPrecision;
8
+ /**
9
+ * Preserve full-precision SVG paths with d3-shape 3.2+, which rounds by default.
10
+ * Earlier versions have no digits() method and already use full precision.
11
+ */
12
+ function withFullPrecision(generator) {
13
+ if (typeof generator.digits === "function") {
14
+ generator.digits(null);
15
+ }
16
+ return generator;
17
+ }
@@ -4,7 +4,22 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getElementTransform = exports.getHtmlElementAncestors = exports.intersectsBBox = exports.clientRectInside = exports.expandRect = exports.clientRectsOverlap = exports.getScaleValues = exports.getRotate = exports.getTranslateValues = exports.elementHeight = exports.elementWidth = exports.requestAnimationFramePolyfill = exports.SCREEN_REFRESH_RATE_MILLISECONDS = exports.entityBounds = exports.elementBBox = exports.contains = void 0;
7
+ exports.SCREEN_REFRESH_RATE_MILLISECONDS = void 0;
8
+ exports.contains = contains;
9
+ exports.elementBBox = elementBBox;
10
+ exports.entityBounds = entityBounds;
11
+ exports.requestAnimationFramePolyfill = requestAnimationFramePolyfill;
12
+ exports.elementWidth = elementWidth;
13
+ exports.elementHeight = elementHeight;
14
+ exports.getTranslateValues = getTranslateValues;
15
+ exports.getRotate = getRotate;
16
+ exports.getScaleValues = getScaleValues;
17
+ exports.clientRectsOverlap = clientRectsOverlap;
18
+ exports.expandRect = expandRect;
19
+ exports.clientRectInside = clientRectInside;
20
+ exports.intersectsBBox = intersectsBBox;
21
+ exports.getHtmlElementAncestors = getHtmlElementAncestors;
22
+ exports.getElementTransform = getElementTransform;
8
23
  var d3 = require("d3");
9
24
  var nativeMath = window.Math;
10
25
  /**
@@ -17,7 +32,6 @@ function contains(parent, child) {
17
32
  }
18
33
  return maybeParent === parent;
19
34
  }
20
- exports.contains = contains;
21
35
  /**
22
36
  * Gets the bounding box of an element.
23
37
  * @param {d3.Selection} element
@@ -34,7 +48,6 @@ function elementBBox(element) {
34
48
  }
35
49
  return bbox;
36
50
  }
37
- exports.elementBBox = elementBBox;
38
51
  function entityBounds(element) {
39
52
  if (element instanceof SVGElement) {
40
53
  return elementBBox(d3.select(element));
@@ -47,7 +60,6 @@ function entityBounds(element) {
47
60
  return { x: 0, y: 0, width: 0, height: 0 };
48
61
  }
49
62
  }
50
- exports.entityBounds = entityBounds;
51
63
  /**
52
64
  * Screen refresh rate which is assumed to be 60fps
53
65
  */
@@ -67,7 +79,6 @@ function requestAnimationFramePolyfill(callback) {
67
79
  setTimeout(callback, exports.SCREEN_REFRESH_RATE_MILLISECONDS);
68
80
  }
69
81
  }
70
- exports.requestAnimationFramePolyfill = requestAnimationFramePolyfill;
71
82
  /**
72
83
  * Calculates the width of the element.
73
84
  * The width includes the padding and the border on the element's left and right sides.
@@ -86,7 +97,6 @@ function elementWidth(elementOrSelection) {
86
97
  + _parseStyleValue(style, "border-left-width")
87
98
  + _parseStyleValue(style, "border-right-width");
88
99
  }
89
- exports.elementWidth = elementWidth;
90
100
  /**
91
101
  * Calculates the height of the element.
92
102
  * The height includes the padding the and the border on the element's top and bottom sides.
@@ -105,14 +115,13 @@ function elementHeight(elementOrSelection) {
105
115
  + _parseStyleValue(style, "border-top-width")
106
116
  + _parseStyleValue(style, "border-bottom-width");
107
117
  }
108
- exports.elementHeight = elementHeight;
109
118
  // taken from the BNF at https://www.w3.org/TR/SVG/coords.html
110
119
  var WSP = "\\s";
111
120
  var NUMBER = "(?:[-+]?[0-9]*\\.?[0-9]+)";
112
- var COMMA_WSP = "(?:(?:" + WSP + "+,?" + WSP + "*)|(?:," + WSP + "*))";
113
- var TRANSLATE_REGEX = new RegExp("translate" + WSP + "*\\(" + WSP + "*(" + NUMBER + ")(?:" + COMMA_WSP + "(" + NUMBER + "))?" + WSP + "*\\)");
114
- var ROTATE_REGEX = new RegExp("rotate" + WSP + "*\\(" + WSP + "*(" + NUMBER + ")" + WSP + "*\\)");
115
- var SCALE_REGEX = new RegExp("scale" + WSP + "*\\(" + WSP + "*(" + NUMBER + ")(?:" + COMMA_WSP + "(" + NUMBER + "))?" + WSP + "*\\)");
121
+ var COMMA_WSP = "(?:(?:".concat(WSP, "+,?").concat(WSP, "*)|(?:,").concat(WSP, "*))");
122
+ var TRANSLATE_REGEX = new RegExp("translate".concat(WSP, "*\\(").concat(WSP, "*(").concat(NUMBER, ")(?:").concat(COMMA_WSP, "(").concat(NUMBER, "))?").concat(WSP, "*\\)"));
123
+ var ROTATE_REGEX = new RegExp("rotate".concat(WSP, "*\\(").concat(WSP, "*(").concat(NUMBER, ")").concat(WSP, "*\\)"));
124
+ var SCALE_REGEX = new RegExp("scale".concat(WSP, "*\\(").concat(WSP, "*(").concat(NUMBER, ")(?:").concat(COMMA_WSP, "(").concat(NUMBER, "))?").concat(WSP, "*\\)"));
116
125
  /**
117
126
  * Accepts selections whose .transform contain a "translate(a, b)" and extracts the a and b
118
127
  */
@@ -126,7 +135,6 @@ function getTranslateValues(el) {
126
135
  return [0, 0];
127
136
  }
128
137
  }
129
- exports.getTranslateValues = getTranslateValues;
130
138
  /**
131
139
  * Accepts selections whose .transform contain a "rotate(angle)" and returns the angle
132
140
  */
@@ -140,7 +148,6 @@ function getRotate(el) {
140
148
  return 0;
141
149
  }
142
150
  }
143
- exports.getRotate = getRotate;
144
151
  function getScaleValues(el) {
145
152
  var match = SCALE_REGEX.exec(el.attr("transform"));
146
153
  if (match != null) {
@@ -151,7 +158,6 @@ function getScaleValues(el) {
151
158
  return [0, 0];
152
159
  }
153
160
  }
154
- exports.getScaleValues = getScaleValues;
155
161
  /**
156
162
  * Checks if the first ClientRect overlaps the second.
157
163
  *
@@ -174,7 +180,6 @@ function clientRectsOverlap(clientRectA, clientRectB) {
174
180
  }
175
181
  return true;
176
182
  }
177
- exports.clientRectsOverlap = clientRectsOverlap;
178
183
  /**
179
184
  * Return a new ClientRect that is the old ClientRect expanded by amount in all directions.
180
185
  * @param rect
@@ -190,7 +195,6 @@ function expandRect(rect, amount) {
190
195
  height: rect.height + amount * 2,
191
196
  };
192
197
  }
193
- exports.expandRect = expandRect;
194
198
  /**
195
199
  * Returns true if and only if innerClientRect is inside outerClientRect.
196
200
  *
@@ -204,7 +208,6 @@ function clientRectInside(innerClientRect, outerClientRect) {
204
208
  nativeMath.floor(innerClientRect.right) <= nativeMath.ceil(outerClientRect.right) &&
205
209
  nativeMath.floor(innerClientRect.bottom) <= nativeMath.ceil(outerClientRect.bottom));
206
210
  }
207
- exports.clientRectInside = clientRectInside;
208
211
  /**
209
212
  * Returns true if the supplied coordinates or Ranges intersect or are contained by bbox.
210
213
  *
@@ -230,7 +233,6 @@ function intersectsBBox(xValOrRange, yValOrRange, bbox, tolerance) {
230
233
  bbox.y + bbox.height >= yRange.min - tolerance &&
231
234
  bbox.y <= yRange.max + tolerance;
232
235
  }
233
- exports.intersectsBBox = intersectsBBox;
234
236
  /**
235
237
  * Create a Range from a number or an object with "min" and "max" defined.
236
238
  *
@@ -266,7 +268,6 @@ function getHtmlElementAncestors(elem) {
266
268
  }
267
269
  return elems;
268
270
  }
269
- exports.getHtmlElementAncestors = getHtmlElementAncestors;
270
271
  /**
271
272
  * Returns the `ICssTransformMatrix` of an element, if defined in its computed
272
273
  * style. Returns `null` if there is no transform on the element.
@@ -280,7 +281,6 @@ function getElementTransform(elem) {
280
281
  style.getPropertyValue("transform");
281
282
  return parseTransformMatrix(transform);
282
283
  }
283
- exports.getElementTransform = getElementTransform;
284
284
  var _MATRIX_REGEX = /^matrix\(([^)]+)\)$/;
285
285
  var _SPLIT_REGEX = /[, ]+/;
286
286
  /**
@@ -27,7 +27,8 @@ export interface IEntityStore<T extends IPositionedEntity> {
27
27
  */
28
28
  addAll(entities: T[], entityBoundsFactory: (entity: T) => IEntityBounds, bounds?: Bounds): void;
29
29
  /**
30
- * Returns the entity closest to a given {Point}
30
+ * Returns the entity closest to a given {Point}. Ties are broken in favor of
31
+ * the entity added last.
31
32
  *
32
33
  * Note that if a {Bounds} was provided to the `addAll` method, entities
33
34
  * outside those bounds will not be returned by this method.
@@ -38,7 +39,8 @@ export interface IEntityStore<T extends IPositionedEntity> {
38
39
  entityNearest(point: Point): T;
39
40
  /**
40
41
  * Returns the entity closest to a given {Point} in the x-dimension. Ties are
41
- * broken with a sort in the y-dimension.
42
+ * broken with a sort in the y-dimension, then in favor of the entity added
43
+ * last.
42
44
  *
43
45
  * @param {Point} [point] Point around which to search for a closest entity
44
46
  * @returns {T} Will return the nearest entity or undefined if none are found
@@ -46,7 +48,8 @@ export interface IEntityStore<T extends IPositionedEntity> {
46
48
  entityNearestX(point: Point): T;
47
49
  /**
48
50
  * Returns the entity closest to a given {Point} in the y-dimension. Ties are
49
- * broken with a sort in the x-dimension.
51
+ * broken with a sort in the x-dimension, then in favor of the entity added
52
+ * last.
50
53
  *
51
54
  * @param {Point} [point] Point around which to search for a closest entity
52
55
  * @returns {T} Will return the nearest entity or undefined if none are found
@@ -20,11 +20,11 @@ var Stacking = require("./stackingUtils");
20
20
  exports.Stacking = Stacking;
21
21
  var Window = require("./windowUtils");
22
22
  exports.Window = Window;
23
- (0, tslib_1.__exportStar)(require("./bucket"), exports);
24
- (0, tslib_1.__exportStar)(require("./callbackSet"), exports);
25
- (0, tslib_1.__exportStar)(require("./coerceD3"), exports);
26
- (0, tslib_1.__exportStar)(require("./entityStore"), exports);
27
- (0, tslib_1.__exportStar)(require("./map"), exports);
28
- (0, tslib_1.__exportStar)(require("./objectUtils"), exports);
29
- (0, tslib_1.__exportStar)(require("./set"), exports);
30
- (0, tslib_1.__exportStar)(require("./transformAwareTranslator"), exports);
23
+ tslib_1.__exportStar(require("./bucket"), exports);
24
+ tslib_1.__exportStar(require("./callbackSet"), exports);
25
+ tslib_1.__exportStar(require("./coerceD3"), exports);
26
+ tslib_1.__exportStar(require("./entityStore"), exports);
27
+ tslib_1.__exportStar(require("./map"), exports);
28
+ tslib_1.__exportStar(require("./objectUtils"), exports);
29
+ tslib_1.__exportStar(require("./set"), exports);
30
+ tslib_1.__exportStar(require("./transformAwareTranslator"), exports);
@@ -4,11 +4,10 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.makeEnum = void 0;
7
+ exports.makeEnum = makeEnum;
8
8
  function makeEnum(values) {
9
9
  return values.reduce(function (obj, v) {
10
10
  obj[v] = v;
11
11
  return obj;
12
12
  }, {});
13
13
  }
14
- exports.makeEnum = makeEnum;
@@ -19,8 +19,8 @@ import { Bounds, Point } from "../core/interfaces";
19
19
  *
20
20
  * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
21
21
  */
22
- export declare type ICssTransformMatrix = [number, number, number, number, number, number];
23
- export declare type ITranslateVector = [number, number];
22
+ export type ICssTransformMatrix = [number, number, number, number, number, number];
23
+ export type ITranslateVector = [number, number];
24
24
  /**
25
25
  * Checks if x is between a and b.
26
26
  *
@@ -4,7 +4,23 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.applyTransform = exports.invertMatrix = exports.multiplyTranslate = exports.premultiplyTranslate = exports.multiplyMatrix = exports.getCumulativeTransform = exports.boundsIntersects = exports.within = exports.degreesToRadians = exports.distanceSquared = exports.range = exports.isValidNumber = exports.isNaN = exports.min = exports.max = exports.clamp = exports.inRange = void 0;
7
+ exports.inRange = inRange;
8
+ exports.clamp = clamp;
9
+ exports.max = max;
10
+ exports.min = min;
11
+ exports.isNaN = isNaN;
12
+ exports.isValidNumber = isValidNumber;
13
+ exports.range = range;
14
+ exports.distanceSquared = distanceSquared;
15
+ exports.degreesToRadians = degreesToRadians;
16
+ exports.within = within;
17
+ exports.boundsIntersects = boundsIntersects;
18
+ exports.getCumulativeTransform = getCumulativeTransform;
19
+ exports.multiplyMatrix = multiplyMatrix;
20
+ exports.premultiplyTranslate = premultiplyTranslate;
21
+ exports.multiplyTranslate = multiplyTranslate;
22
+ exports.invertMatrix = invertMatrix;
23
+ exports.applyTransform = applyTransform;
8
24
  var d3 = require("d3");
9
25
  var domUtils_1 = require("./domUtils");
10
26
  var nativeMath = window.Math;
@@ -20,7 +36,6 @@ var _IDENTITY_TRANSFORM = [1, 0, 0, 1, 0, 0];
20
36
  function inRange(x, a, b) {
21
37
  return (nativeMath.min(a, b) <= x && x <= nativeMath.max(a, b));
22
38
  }
23
- exports.inRange = inRange;
24
39
  /**
25
40
  * Clamps x to the range [min, max].
26
41
  *
@@ -32,28 +47,24 @@ exports.inRange = inRange;
32
47
  function clamp(x, min, max) {
33
48
  return nativeMath.min(nativeMath.max(min, x), max);
34
49
  }
35
- exports.clamp = clamp;
36
50
  function max(array, firstArg, secondArg) {
37
51
  var accessor = typeof (firstArg) === "function" ? firstArg : null;
38
52
  var defaultValue = accessor == null ? firstArg : secondArg;
39
53
  var maxValue = accessor == null ? d3.max(array) : d3.max(array, accessor);
40
54
  return maxValue !== undefined ? maxValue : defaultValue;
41
55
  }
42
- exports.max = max;
43
56
  function min(array, firstArg, secondArg) {
44
57
  var accessor = typeof (firstArg) === "function" ? firstArg : null;
45
58
  var defaultValue = accessor == null ? firstArg : secondArg;
46
59
  var minValue = accessor == null ? d3.min(array) : d3.min(array, accessor);
47
60
  return minValue !== undefined ? minValue : defaultValue;
48
61
  }
49
- exports.min = min;
50
62
  /**
51
63
  * Returns true **only** if x is NaN
52
64
  */
53
65
  function isNaN(n) {
54
66
  return n !== n;
55
67
  }
56
- exports.isNaN = isNaN;
57
68
  /**
58
69
  * Returns true if the argument is a number, which is not NaN
59
70
  * Numbers represented as strings do not pass this function
@@ -61,7 +72,6 @@ exports.isNaN = isNaN;
61
72
  function isValidNumber(n) {
62
73
  return typeof n === "number" && n - n < 1;
63
74
  }
64
- exports.isValidNumber = isValidNumber;
65
75
  /**
66
76
  * Generates an array of consecutive, strictly increasing numbers
67
77
  * in the range [start, stop) separeted by step
@@ -78,7 +88,6 @@ function range(start, stop, step) {
78
88
  }
79
89
  return range;
80
90
  }
81
- exports.range = range;
82
91
  /**
83
92
  * Returns the square of the distance between two points
84
93
  *
@@ -89,11 +98,9 @@ exports.range = range;
89
98
  function distanceSquared(p1, p2) {
90
99
  return nativeMath.pow(p2.y - p1.y, 2) + nativeMath.pow(p2.x - p1.x, 2);
91
100
  }
92
- exports.distanceSquared = distanceSquared;
93
101
  function degreesToRadians(degree) {
94
102
  return degree / 360 * nativeMath.PI * 2;
95
103
  }
96
- exports.degreesToRadians = degreesToRadians;
97
104
  /**
98
105
  * Returns if the point is within the bounds. Points along
99
106
  * the bounds are considered "within" as well.
@@ -106,7 +113,6 @@ function within(p, bounds) {
106
113
  && bounds.topLeft.y <= p.y
107
114
  && bounds.bottomRight.y >= p.y;
108
115
  }
109
- exports.within = within;
110
116
  /**
111
117
  * Returns whether the first bounds intersects the second bounds.
112
118
  * Pass primitive numbers directly for performance.
@@ -119,7 +125,6 @@ function boundsIntersects(aX, aY, aWidth, aHeight, bX, bY, bWidth, bHeight) {
119
125
  aY <= bY + bHeight &&
120
126
  bY <= aY + aHeight;
121
127
  }
122
- exports.boundsIntersects = boundsIntersects;
123
128
  /**
124
129
  * Returns a `ICssTransformMatrix` representing the cumulative transformation of
125
130
  * the element and all its parents. This transform converts from top-level
@@ -160,7 +165,6 @@ function getCumulativeTransform(element) {
160
165
  }
161
166
  return transform;
162
167
  }
163
- exports.getCumulativeTransform = getCumulativeTransform;
164
168
  /**
165
169
  * Straightforward matrix multiplication of homogenized css transform matrices.
166
170
  */
@@ -174,7 +178,6 @@ function multiplyMatrix(a, b) {
174
178
  a[1] * b[4] + a[3] * b[5] + a[5],
175
179
  ];
176
180
  }
177
- exports.multiplyMatrix = multiplyMatrix;
178
181
  /**
179
182
  * Prepends translation to transformation matrix.
180
183
  *
@@ -187,7 +190,6 @@ function premultiplyTranslate(v, b) {
187
190
  b[5] + v[1],
188
191
  ];
189
192
  }
190
- exports.premultiplyTranslate = premultiplyTranslate;
191
193
  /**
192
194
  * Appends translation to transformation matrix.
193
195
  *
@@ -200,7 +202,6 @@ function multiplyTranslate(a, v) {
200
202
  a[1] * v[0] + a[3] * v[1] + a[5],
201
203
  ];
202
204
  }
203
- exports.multiplyTranslate = multiplyTranslate;
204
205
  /**
205
206
  * Analytical inverse of a `ICssTransformMatrix` analogous to a non-singular
206
207
  * homogenous 3x3 matrix.
@@ -223,7 +224,6 @@ function invertMatrix(a) {
223
224
  inverseDeterminant * (a[1] * a[4] + -a[0] * a[5]),
224
225
  ];
225
226
  }
226
- exports.invertMatrix = invertMatrix;
227
227
  /**
228
228
  * Applies the `ICssTransformMatrix` to the `Point`.
229
229
  *
@@ -235,4 +235,3 @@ function applyTransform(a, p) {
235
235
  y: a[1] * p.x + a[3] * p.y + a[5],
236
236
  };
237
237
  }
238
- exports.applyTransform = applyTransform;
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.assign = void 0;
7
+ exports.assign = assign;
8
8
  /**
9
9
  * Polyfill for Object.assign
10
10
  */
@@ -24,4 +24,3 @@ function assign() {
24
24
  }
25
25
  return result;
26
26
  }
27
- exports.assign = assign;
@@ -19,7 +19,7 @@ export declare enum QueryPredicateResult {
19
19
  * Returns the absolute distance to the nearest point on the edge of bounds or 0
20
20
  * if the point is in bounds.
21
21
  */
22
- export declare type IDistanceFunction = (bounds: RTreeBounds, p: Point) => number;
22
+ export type IDistanceFunction = (bounds: RTreeBounds, p: Point) => number;
23
23
  /**
24
24
  * Creates a node predicate for use with `RTree.queryNodes`
25
25
  *
@@ -32,6 +32,9 @@ export declare type IDistanceFunction = (bounds: RTreeBounds, p: Point) => numbe
32
32
  export declare function createMinimizingNodePredicate<T>(point: Point, nearFn: IDistanceFunction, farFn: IDistanceFunction): (node: RTreeNode<T>) => QueryPredicateResult;
33
33
  /**
34
34
  * Create a `Array.sort` function from a query point and a distance function.
35
+ *
36
+ * Nodes are sorted from farthest to nearest. Ties are sorted from first
37
+ * inserted to last inserted.
35
38
  */
36
39
  export declare function createNodeSort<T>(point: Point, distanceFn: IDistanceFunction): (a: RTreeNode<T>, b: RTreeNode<T>) => number;
37
40
  /**
@@ -63,6 +66,9 @@ export declare class RTree<T> {
63
66
  * Nearness is measured as the absolute distance from the query point to the
64
67
  * nearest edge of the node bounds. If the node bounds contains the query
65
68
  * point, the distance is 0.
69
+ *
70
+ * The results are equally near and sorted by insertion order, ending with
71
+ * the last inserted value.
66
72
  */
67
73
  locateNearest(xy: Point): T[];
68
74
  /**
@@ -72,7 +78,8 @@ export declare class RTree<T> {
72
78
  * query's x point to the nearest edge of the node bounds. If the node
73
79
  * bounds contains the query point, the distance is 0.
74
80
  *
75
- * The results are sorted by y-coordinate nearness.
81
+ * The results are sorted by y-coordinate nearness, then by insertion
82
+ * order, ending with the nearest, last inserted value.
76
83
  */
77
84
  locateNearestX(xy: Point): T[];
78
85
  /**
@@ -82,7 +89,8 @@ export declare class RTree<T> {
82
89
  * query's y point to the nearest edge of the node bounds. If the node
83
90
  * bounds contains the query point, the distance is 0.
84
91
  *
85
- * The results are sorted by x-coordinate nearness.
92
+ * The results are sorted by x-coordinate nearness, then by insertion
93
+ * order, ending with the nearest, last inserted value.
86
94
  */
87
95
  locateNearestY(xy: Point): T[];
88
96
  intersect(bounds: RTreeBounds): T[];
@@ -98,6 +106,7 @@ export declare class RTreeNode<T> {
98
106
  entries: RTreeNode<T>[];
99
107
  parent: RTreeNode<T>;
100
108
  value: T;
109
+ insertionIndex: number;
101
110
  constructor(leaf: boolean);
102
111
  /**
103
112
  * Returns `true` iff this node has more children than the `maxNodeChildren`
@@ -4,7 +4,9 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.RTreeBounds = exports.RTreeNode = exports.RTree = exports.createNodeSort = exports.createMinimizingNodePredicate = exports.QueryPredicateResult = void 0;
7
+ exports.RTreeBounds = exports.RTreeNode = exports.RTree = exports.QueryPredicateResult = void 0;
8
+ exports.createMinimizingNodePredicate = createMinimizingNodePredicate;
9
+ exports.createNodeSort = createNodeSort;
8
10
  var rTreeSplitStrategies_1 = require("./rTreeSplitStrategies");
9
11
  /**
10
12
  * The maximum number of children in an r-tree node before we attempt to split.
@@ -28,7 +30,7 @@ var QueryPredicateResult;
28
30
  QueryPredicateResult[QueryPredicateResult["PASS"] = 0] = "PASS";
29
31
  QueryPredicateResult[QueryPredicateResult["FAIL"] = 1] = "FAIL";
30
32
  QueryPredicateResult[QueryPredicateResult["PASS_AND_OVERWRITE"] = 2] = "PASS_AND_OVERWRITE";
31
- })(QueryPredicateResult = exports.QueryPredicateResult || (exports.QueryPredicateResult = {}));
33
+ })(QueryPredicateResult || (exports.QueryPredicateResult = QueryPredicateResult = {}));
32
34
  /**
33
35
  * Creates a node predicate for use with `RTree.queryNodes`
34
36
  *
@@ -72,16 +74,18 @@ function createMinimizingNodePredicate(point, nearFn, farFn) {
72
74
  }
73
75
  };
74
76
  }
75
- exports.createMinimizingNodePredicate = createMinimizingNodePredicate;
76
77
  /**
77
78
  * Create a `Array.sort` function from a query point and a distance function.
79
+ *
80
+ * Nodes are sorted from farthest to nearest. Ties are sorted from first
81
+ * inserted to last inserted.
78
82
  */
79
83
  function createNodeSort(point, distanceFn) {
80
84
  return function (a, b) {
81
- return distanceFn(b.bounds, point) - distanceFn(a.bounds, point);
85
+ var distanceDifference = distanceFn(b.bounds, point) - distanceFn(a.bounds, point);
86
+ return distanceDifference !== 0 ? distanceDifference : a.insertionIndex - b.insertionIndex;
82
87
  };
83
88
  }
84
- exports.createNodeSort = createNodeSort;
85
89
  /**
86
90
  * R-Tree is a multidimensional spatial region tree. It stores entries that have
87
91
  * arbitrarily overlapping bounding boxes and supports efficient point and
@@ -119,6 +123,7 @@ var RTree = /** @class */ (function () {
119
123
  }
120
124
  // Insert new value node into leaf node
121
125
  var valueNode = RTreeNode.valueNode(bounds, value);
126
+ valueNode.insertionIndex = this.size;
122
127
  node.insert(valueNode);
123
128
  this.size += 1;
124
129
  // While node overflows, split and walk up
@@ -139,10 +144,14 @@ var RTree = /** @class */ (function () {
139
144
  * Nearness is measured as the absolute distance from the query point to the
140
145
  * nearest edge of the node bounds. If the node bounds contains the query
141
146
  * point, the distance is 0.
147
+ *
148
+ * The results are equally near and sorted by insertion order, ending with
149
+ * the last inserted value.
142
150
  */
143
151
  RTree.prototype.locateNearest = function (xy) {
144
152
  var predicate = createMinimizingNodePredicate(xy, RTreeBounds.distanceSquaredToNearEdge, RTreeBounds.distanceSquaredToFarEdge);
145
153
  var nodes = this.queryNodes(predicate);
154
+ nodes.sort(function (a, b) { return a.insertionIndex - b.insertionIndex; });
146
155
  return nodes.map(function (node) { return node.value; });
147
156
  };
148
157
  /**
@@ -152,7 +161,8 @@ var RTree = /** @class */ (function () {
152
161
  * query's x point to the nearest edge of the node bounds. If the node
153
162
  * bounds contains the query point, the distance is 0.
154
163
  *
155
- * The results are sorted by y-coordinate nearness.
164
+ * The results are sorted by y-coordinate nearness, then by insertion
165
+ * order, ending with the nearest, last inserted value.
156
166
  */
157
167
  RTree.prototype.locateNearestX = function (xy) {
158
168
  var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeX, RTreeBounds.absoluteDistanceToFarEdgeX);
@@ -167,7 +177,8 @@ var RTree = /** @class */ (function () {
167
177
  * query's y point to the nearest edge of the node bounds. If the node
168
178
  * bounds contains the query point, the distance is 0.
169
179
  *
170
- * The results are sorted by x-coordinate nearness.
180
+ * The results are sorted by x-coordinate nearness, then by insertion
181
+ * order, ending with the nearest, last inserted value.
171
182
  */
172
183
  RTree.prototype.locateNearestY = function (xy) {
173
184
  var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeY, RTreeBounds.absoluteDistanceToFarEdgeY);
@@ -242,6 +253,7 @@ var RTreeNode = /** @class */ (function () {
242
253
  this.entries = [];
243
254
  this.parent = null;
244
255
  this.value = null;
256
+ this.insertionIndex = null;
245
257
  }
246
258
  RTreeNode.valueNode = function (bounds, value) {
247
259
  var node = new RTreeNode(true);
@@ -3,7 +3,7 @@
3
3
  * @license MIT
4
4
  */
5
5
  import { RTreeNode } from "./rTree";
6
- export declare type NodePair<T> = [RTreeNode<T>, RTreeNode<T>];
6
+ export type NodePair<T> = [RTreeNode<T>, RTreeNode<T>];
7
7
  export interface IRTreeSplitStrategy {
8
8
  split: <T>(entries: RTreeNode<T>[], nodes: NodePair<T>) => void;
9
9
  }
@@ -6,7 +6,7 @@ import { Dataset } from "../core/dataset";
6
6
  import { IAccessor } from "../core/interfaces";
7
7
  import type { MemoizedFunction } from "lodash";
8
8
  import * as Utils from "./";
9
- export declare type GenericStackedDatum<D> = {
9
+ export type GenericStackedDatum<D> = {
10
10
  value: number;
11
11
  offset: number;
12
12
  axisValue: D;
@@ -14,12 +14,12 @@ export declare type GenericStackedDatum<D> = {
14
14
  originalIndex: number;
15
15
  originalDataset: Dataset;
16
16
  };
17
- export declare type StackExtent<D> = {
17
+ export type StackExtent<D> = {
18
18
  extent: number;
19
19
  axisValue: D;
20
20
  stackedDatum: GenericStackedDatum<D>;
21
21
  };
22
- export declare type StackedDatum = GenericStackedDatum<string>;
22
+ export type StackedDatum = GenericStackedDatum<string>;
23
23
  /**
24
24
  * Option type for stacking direction. By default, stacked bar and area charts
25
25
  * put the first data series at the bottom of the axis ("bottomup"), but this
@@ -30,13 +30,13 @@ export declare const IStackingOrder: {
30
30
  topdown: "topdown";
31
31
  bottomup: "bottomup";
32
32
  };
33
- export declare type IStackingOrder = keyof typeof IStackingOrder;
34
- export declare type GenericStackingResult<D> = Utils.Map<Dataset, Utils.Map<string | number, GenericStackedDatum<D>>>;
33
+ export type IStackingOrder = keyof typeof IStackingOrder;
34
+ export type GenericStackingResult<D> = Utils.Map<Dataset, Utils.Map<string | number, GenericStackedDatum<D>>>;
35
35
  /**
36
36
  * Map of Dataset to stacks.
37
37
  * @deprecated
38
38
  */
39
- export declare type StackingResult = GenericStackingResult<string>;
39
+ export type StackingResult = GenericStackingResult<string>;
40
40
  /**
41
41
  * Computes the StackingResult (value and offset) for each data point in each Dataset.
42
42
  *