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
package/README.md CHANGED
@@ -11,6 +11,13 @@ Plottable is used and developed at [Palantir Technologies](http://palantir.com/)
11
11
 
12
12
  ## Quick Start
13
13
 
14
+ Plottable requires D3 7 (`d3@^7.9.0`) and a browser with ES2015 support.
15
+ When loading D3 with a script tag or RequireJS, use `d3/dist/d3.min.js`.
16
+ CommonJS consumers need Node.js 22.12 or later to load D3's ES modules;
17
+ browser applications can use a bundler with ES module support.
18
+ TypeScript consumers need TypeScript 5 or later for the D3 type definitions.
19
+ The `Category20`, `Category20b`, and `Category20c` color scales retain their original palettes.
20
+
14
21
  - Get Plottable:
15
22
  - npm: `npm install --save plottable`
16
23
  - yarn: `yarn add plottable`
@@ -38,8 +45,8 @@ If you run into any problems using Plottable, please let us know. We want Plotta
38
45
  ## Development
39
46
 
40
47
  - Clone the repo
41
- - Install local dependencies `yarn install`
42
- - Run `yarn build` to build the dependencies
48
+ - Use the Node.js version in `.nvmrc`, then run `yarn install` and `yarn build`
49
+ - Run `yarn playwright install chromium` to install the browser used by `yarn test`
43
50
  - Run `yarn start` and it will spin up a server (pointed at http://localhost:9999) and begin compiling the typescript code
44
51
  - Navigate to `http://localhost:9999/quicktests/` and choose a directory to view visual tests
45
52
 
@@ -5,7 +5,7 @@
5
5
  import * as d3 from "d3";
6
6
  import { AttributeToAppliedProjector, SimpleSelection } from "../core/interfaces";
7
7
  import { IAnimator } from "./animator";
8
- export declare type EaseFn = (normalizedTime: number) => number;
8
+ export type EaseFn = (normalizedTime: number) => number;
9
9
  export declare const EaseName: {
10
10
  linear: "linear";
11
11
  circle: "circle";
@@ -48,7 +48,7 @@ export declare const EaseName: {
48
48
  /**
49
49
  * Known ease types that animator's .ease() methods understand
50
50
  */
51
- export declare type EaseName = keyof typeof EaseName;
51
+ export type EaseName = keyof typeof EaseName;
52
52
  /**
53
53
  * An Animator with easing and configurable durations and delays.
54
54
  */
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.Easing = exports.EaseName = void 0;
8
- var d3Ease = require("d3-ease");
8
+ var d3Ease = require("d3");
9
9
  var coerceD3_1 = require("../utils/coerceD3");
10
10
  var makeEnum_1 = require("../utils/makeEnum");
11
11
  var EASE_NAME_MAPPING = {
@@ -5,5 +5,5 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  var tslib_1 = require("tslib");
8
- (0, tslib_1.__exportStar)(require("./easingAnimator"), exports);
9
- (0, tslib_1.__exportStar)(require("./nullAnimator"), exports);
8
+ tslib_1.__exportStar(require("./easingAnimator"), exports);
9
+ tslib_1.__exportStar(require("./nullAnimator"), exports);
@@ -13,7 +13,7 @@ export declare const AxisOrientation: {
13
13
  bottom: "bottom";
14
14
  right: "right";
15
15
  };
16
- export declare type AxisOrientation = keyof typeof AxisOrientation;
16
+ export type AxisOrientation = keyof typeof AxisOrientation;
17
17
  export declare class Axis<D> extends Component {
18
18
  /**
19
19
  * The css class applied to each end tick mark (the line on the end tick).
@@ -15,7 +15,7 @@ var Utils = require("../utils");
15
15
  var makeEnum_1 = require("../utils/makeEnum");
16
16
  exports.AxisOrientation = (0, makeEnum_1.makeEnum)(["bottom", "left", "right", "top"]);
17
17
  var Axis = /** @class */ (function (_super) {
18
- (0, tslib_1.__extends)(Axis, _super);
18
+ tslib_1.__extends(Axis, _super);
19
19
  /**
20
20
  * Constructs an Axis.
21
21
  * An Axis is a visual representation of a Scale.
@@ -184,8 +184,8 @@ var Axis = /** @class */ (function (_super) {
184
184
  }
185
185
  // clearing to remove outdated font-size classes
186
186
  this._tickLabelContainer.attr("class", null)
187
- .classed(Axis.TICK_LABEL_CLASS + "-container", true)
188
- .classed("label-" + this._tickLabelFontSize, true);
187
+ .classed("".concat(Axis.TICK_LABEL_CLASS, "-container"), true)
188
+ .classed("label-".concat(this._tickLabelFontSize), true);
189
189
  };
190
190
  /*
191
191
  * Function for generating tick values in data-space (as opposed to pixel values).
@@ -281,7 +281,7 @@ var Axis = /** @class */ (function (_super) {
281
281
  }
282
282
  });
283
283
  var bindElements = function (selection, elementName, className) {
284
- var elementsUpdate = selection.selectAll("." + className).data(annotatedTicks);
284
+ var elementsUpdate = selection.selectAll(".".concat(className)).data(annotatedTicks);
285
285
  var elements = elementsUpdate
286
286
  .enter()
287
287
  .append(elementName)
@@ -356,7 +356,7 @@ var Axis = /** @class */ (function (_super) {
356
356
  transform: function (d) {
357
357
  var xTranslate = isHorizontal ? positionF(d) : rectangleOffsetF(d);
358
358
  var yTranslate = isHorizontal ? rectangleOffsetF(d) : positionF(d);
359
- return "translate(" + xTranslate + "," + yTranslate + ")";
359
+ return "translate(".concat(xTranslate, ",").concat(yTranslate, ")");
360
360
  },
361
361
  visibility: visibilityF,
362
362
  })
@@ -13,7 +13,7 @@ var label_1 = require("../components/label");
13
13
  var Utils = require("../utils");
14
14
  var axis_1 = require("./axis");
15
15
  var Category = /** @class */ (function (_super) {
16
- (0, tslib_1.__extends)(Category, _super);
16
+ tslib_1.__extends(Category, _super);
17
17
  /**
18
18
  * Constructs a Category Axis.
19
19
  *
@@ -227,7 +227,7 @@ var Category = /** @class */ (function (_super) {
227
227
  // aligned with the side of the ticks
228
228
  if (self.orientation() === "left" && width > self._tickLabelMaxWidth) {
229
229
  var cutOffWidth = width - self._tickLabelMaxWidth;
230
- var newTransform = container.attr("transform") + " translate(" + cutOffWidth + ", 0)";
230
+ var newTransform = "".concat(container.attr("transform"), " translate(").concat(cutOffWidth, ", 0)");
231
231
  container.attr("transform", newTransform);
232
232
  }
233
233
  width = Math.min(width, self._tickLabelMaxWidth);
@@ -288,10 +288,11 @@ var Category = /** @class */ (function (_super) {
288
288
  return _this._wrapper.wrap(_this.formatter()(s), _this._measurer, width, height);
289
289
  });
290
290
  // HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
291
- var widthFn = (this.isHorizontal() && this._tickLabelAngle === 0) ? d3.sum : Utils.Math.max;
292
- var heightFn = (this.isHorizontal() && this._tickLabelAngle === 0) ? Utils.Math.max : d3.sum;
293
- var usedWidth = widthFn(wrappingResults, function (t) { return _this._measurer.measure(t.wrappedText).width; }, 0);
294
- var usedHeight = heightFn(wrappingResults, function (t) { return _this._measurer.measure(t.wrappedText).height; }, 0);
291
+ var widths = wrappingResults.map(function (result) { return _this._measurer.measure(result.wrappedText).width; });
292
+ var heights = wrappingResults.map(function (result) { return _this._measurer.measure(result.wrappedText).height; });
293
+ var horizontal = this.isHorizontal() && this._tickLabelAngle === 0;
294
+ var usedWidth = horizontal ? d3.sum(widths) : Utils.Math.max(widths, 0);
295
+ var usedHeight = horizontal ? Utils.Math.max(heights, 0) : d3.sum(heights);
295
296
  // If the tick labels are rotated, reverse usedWidth and usedHeight
296
297
  // HACKHACK: https://github.com/palantir/svg-typewriter/issues/25
297
298
  if (this._tickLabelAngle !== 0) {
@@ -333,7 +334,7 @@ var Category = /** @class */ (function (_super) {
333
334
  this._drawTicks(stepWidth, tickLabels);
334
335
  var xTranslate = this.orientation() === "right" ? this._tickSpaceRequired() : 0;
335
336
  var yTranslate = this.orientation() === "bottom" ? this._tickSpaceRequired() : 0;
336
- this._tickLabelContainer.attr("transform", "translate(" + xTranslate + "," + yTranslate + ")");
337
+ this._tickLabelContainer.attr("transform", "translate(".concat(xTranslate, ",").concat(yTranslate, ")"));
337
338
  // hide ticks and labels that overflow the axis
338
339
  this._showAllTickMarks();
339
340
  this._showAllTickLabels();
@@ -5,6 +5,6 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  var tslib_1 = require("tslib");
8
- (0, tslib_1.__exportStar)(require("./categoryAxis"), exports);
9
- (0, tslib_1.__exportStar)(require("./numericAxis"), exports);
10
- (0, tslib_1.__exportStar)(require("./timeAxis"), exports);
8
+ tslib_1.__exportStar(require("./categoryAxis"), exports);
9
+ tslib_1.__exportStar(require("./numericAxis"), exports);
10
+ tslib_1.__exportStar(require("./timeAxis"), exports);
@@ -12,7 +12,7 @@ var Formatters = require("../core/formatters");
12
12
  var Utils = require("../utils");
13
13
  var axis_1 = require("./axis");
14
14
  var Numeric = /** @class */ (function (_super) {
15
- (0, tslib_1.__extends)(Numeric, _super);
15
+ tslib_1.__extends(Numeric, _super);
16
16
  /**
17
17
  * Constructs a Numeric Axis.
18
18
  *
@@ -15,12 +15,12 @@ export declare const TimeInterval: {
15
15
  month: "month";
16
16
  year: "year";
17
17
  };
18
- export declare type TimeInterval = keyof typeof TimeInterval;
18
+ export type TimeInterval = keyof typeof TimeInterval;
19
19
  /**
20
20
  * Defines a configuration for a Time Axis tier.
21
21
  * For details on how ticks are generated see: https://github.com/mbostock/d3/wiki/Time-Scales#ticks
22
22
  */
23
- export declare type TimeAxisTierConfiguration = {
23
+ export type TimeAxisTierConfiguration = {
24
24
  /**
25
25
  * The time unit associated with this configuration (seconds, minutes, hours, etc).
26
26
  */
@@ -40,7 +40,7 @@ export declare type TimeAxisTierConfiguration = {
40
40
  * Each configuration will be shown on a different tier.
41
41
  * Currently, up to two tiers are supported.
42
42
  */
43
- export declare type TimeAxisConfiguration = TimeAxisTierConfiguration[];
43
+ export type TimeAxisConfiguration = TimeAxisTierConfiguration[];
44
44
  /**
45
45
  * Possible orientations for a Time Axis.
46
46
  */
@@ -48,12 +48,12 @@ export declare const TimeAxisOrientation: {
48
48
  top: "top";
49
49
  bottom: "bottom";
50
50
  };
51
- export declare type TimeAxisOrientation = keyof typeof TimeAxisOrientation;
51
+ export type TimeAxisOrientation = keyof typeof TimeAxisOrientation;
52
52
  export declare const TierLabelPosition: {
53
53
  center: "center";
54
54
  between: "between";
55
55
  };
56
- export declare type TierLabelPosition = keyof typeof TierLabelPosition;
56
+ export type TierLabelPosition = keyof typeof TierLabelPosition;
57
57
  export declare class Time extends Axis<Date> {
58
58
  /**
59
59
  * The CSS class applied to each Time Axis tier
@@ -29,7 +29,7 @@ exports.TimeInterval = (0, makeEnum_1.makeEnum)([
29
29
  exports.TimeAxisOrientation = (0, makeEnum_1.makeEnum)(["top", "bottom"]);
30
30
  exports.TierLabelPosition = (0, makeEnum_1.makeEnum)(["between", "center"]);
31
31
  var Time = /** @class */ (function (_super) {
32
- (0, tslib_1.__extends)(Time, _super);
32
+ tslib_1.__extends(Time, _super);
33
33
  /**
34
34
  * Constructs a Time Axis.
35
35
  *
@@ -63,8 +63,8 @@ var Time = /** @class */ (function (_super) {
63
63
  this._tierLabelContainers.forEach(function (container) {
64
64
  // clearing to remove outdated font-size classes
65
65
  container.attr("class", null)
66
- .classed(axis_1.Axis.TICK_LABEL_CLASS + "-container", true)
67
- .classed("label-" + _this._tickLabelFontSize, true);
66
+ .classed("".concat(axis_1.Axis.TICK_LABEL_CLASS, "-container"), true)
67
+ .classed("label-".concat(_this._tickLabelFontSize), true);
68
68
  });
69
69
  }
70
70
  return _super.prototype.tickLabelFontSize.call(this, fontSize);
@@ -214,8 +214,8 @@ var Time = /** @class */ (function (_super) {
214
214
  for (var i = 0; i < this._numTiers; ++i) {
215
215
  var tierContainer = this.content().append("g").classed(Time.TIME_AXIS_TIER_CLASS, true);
216
216
  this._tierLabelContainers.push(tierContainer.append("g")
217
- .classed(axis_1.Axis.TICK_LABEL_CLASS + "-container", true)
218
- .classed("label-" + this._tickLabelFontSize, true));
217
+ .classed("".concat(axis_1.Axis.TICK_LABEL_CLASS, "-container"), true)
218
+ .classed("label-".concat(this._tickLabelFontSize), true));
219
219
  this._tierMarkContainers.push(tierContainer.append("g").classed(axis_1.Axis.TICK_MARK_CLASS + "-container", true));
220
220
  this._tierBaselines.push(tierContainer.append("line").classed("baseline", true));
221
221
  }
@@ -286,7 +286,7 @@ var Time = /** @class */ (function (_super) {
286
286
  var tickLabels = tickLabelsUpdate.merge(tickLabelsEnter);
287
287
  var textSelection = tickLabels.selectAll("text");
288
288
  if (textSelection.size() > 0) {
289
- textSelection.attr("transform", "translate(" + xTranslate + "," + yTranslate + ")");
289
+ textSelection.attr("transform", "translate(".concat(xTranslate, ",").concat(yTranslate, ")"));
290
290
  }
291
291
  tickLabelsUpdate.exit().remove();
292
292
  tickLabels.attr("transform", function (d) { return "translate(" + _this._scale.scale(d) + ",0)"; });
@@ -5,8 +5,8 @@
5
5
  import * as d3 from "d3";
6
6
  import { Bounds, Point, SimpleSelection, SpaceRequest } from "../core/interfaces";
7
7
  import { ComponentContainer } from "./componentContainer";
8
- export declare type ComponentCallback = (component: Component) => void;
9
- export declare type IResizeHandler = (size: {
8
+ export type ComponentCallback = (component: Component) => void;
9
+ export type IResizeHandler = (size: {
10
10
  height: number;
11
11
  width: number;
12
12
  }) => void;
@@ -15,13 +15,13 @@ export declare const XAlignment: {
15
15
  left: "left";
16
16
  right: "right";
17
17
  };
18
- export declare type XAlignment = keyof typeof XAlignment;
18
+ export type XAlignment = keyof typeof XAlignment;
19
19
  export declare const YAlignment: {
20
20
  center: "center";
21
21
  top: "top";
22
22
  bottom: "bottom";
23
23
  };
24
- export declare type YAlignment = keyof typeof YAlignment;
24
+ export type YAlignment = keyof typeof YAlignment;
25
25
  /**
26
26
  * Components are the core logical units that build Plottable visualizations.
27
27
  *
@@ -195,10 +195,10 @@ var Component = /** @class */ (function () {
195
195
  };
196
196
  if (this._element != null) {
197
197
  this._element.styles({
198
- left: originX + "px",
199
- height: height + "px",
200
- top: originY + "px",
201
- width: width + "px",
198
+ left: "".concat(originX, "px"),
199
+ height: "".concat(height, "px"),
200
+ top: "".concat(originY, "px"),
201
+ width: "".concat(width, "px"),
202
202
  });
203
203
  }
204
204
  if (this._resizeHandler != null) {
@@ -13,7 +13,7 @@ var component_1 = require("./component");
13
13
  * It will not do anything if instantiated directly.
14
14
  */
15
15
  var ComponentContainer = /** @class */ (function (_super) {
16
- (0, tslib_1.__extends)(ComponentContainer, _super);
16
+ tslib_1.__extends(ComponentContainer, _super);
17
17
  function ComponentContainer() {
18
18
  var _this = _super.call(this) || this;
19
19
  _this._detachCallback = function (component) { return _this.remove(component); };
@@ -6,7 +6,7 @@ import * as d3 from "d3";
6
6
  import { Bounds } from "../core/interfaces";
7
7
  import * as Interactions from "../interactions";
8
8
  import { SelectionBoxLayer } from "./selectionBoxLayer";
9
- export declare type DragBoxCallback = (bounds: Bounds) => void;
9
+ export type DragBoxCallback = (bounds: Bounds) => void;
10
10
  export declare class DragBoxLayer extends SelectionBoxLayer {
11
11
  private _dragInteraction;
12
12
  private _detectionEdgeT;
@@ -12,7 +12,7 @@ var coerceD3_1 = require("../utils/coerceD3");
12
12
  var _1 = require("./");
13
13
  var selectionBoxLayer_1 = require("./selectionBoxLayer");
14
14
  var DragBoxLayer = /** @class */ (function (_super) {
15
- (0, tslib_1.__extends)(DragBoxLayer, _super);
15
+ tslib_1.__extends(DragBoxLayer, _super);
16
16
  /**
17
17
  * Constructs a DragBoxLayer.
18
18
  *
@@ -10,7 +10,7 @@ var guideLineLayer_1 = require("../components/guideLineLayer");
10
10
  var Interactions = require("../interactions");
11
11
  var Utils = require("../utils");
12
12
  var DragLineLayer = /** @class */ (function (_super) {
13
- (0, tslib_1.__extends)(DragLineLayer, _super);
13
+ tslib_1.__extends(DragLineLayer, _super);
14
14
  function DragLineLayer(orientation) {
15
15
  var _this = _super.call(this, orientation) || this;
16
16
  _this._detectionRadius = 3;
@@ -39,7 +39,7 @@ function gridPositionFactory(scale, between, orderedTicks) {
39
39
  };
40
40
  }
41
41
  var Gridlines = /** @class */ (function (_super) {
42
- (0, tslib_1.__extends)(Gridlines, _super);
42
+ tslib_1.__extends(Gridlines, _super);
43
43
  /**
44
44
  * @constructor
45
45
  * @param {Scale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired.
@@ -9,7 +9,7 @@ var tslib_1 = require("tslib");
9
9
  var Utils = require("../utils");
10
10
  var componentContainer_1 = require("./componentContainer");
11
11
  var Group = /** @class */ (function (_super) {
12
- (0, tslib_1.__extends)(Group, _super);
12
+ tslib_1.__extends(Group, _super);
13
13
  /**
14
14
  * Constructs a Group.
15
15
  *
@@ -14,7 +14,7 @@ var PropertyMode;
14
14
  PropertyMode[PropertyMode["PIXEL"] = 1] = "PIXEL";
15
15
  })(PropertyMode || (PropertyMode = {}));
16
16
  var GuideLineLayer = /** @class */ (function (_super) {
17
- (0, tslib_1.__extends)(GuideLineLayer, _super);
17
+ tslib_1.__extends(GuideLineLayer, _super);
18
18
  function GuideLineLayer(orientation) {
19
19
  var _this = _super.call(this) || this;
20
20
  _this._mode = PropertyMode.VALUE;
@@ -5,17 +5,17 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  var tslib_1 = require("tslib");
8
- (0, tslib_1.__exportStar)(require("./dragBoxLayer"), exports);
9
- (0, tslib_1.__exportStar)(require("./dragLineLayer"), exports);
10
- (0, tslib_1.__exportStar)(require("./gridlines"), exports);
11
- (0, tslib_1.__exportStar)(require("./group"), exports);
12
- (0, tslib_1.__exportStar)(require("./guideLineLayer"), exports);
13
- (0, tslib_1.__exportStar)(require("./interpolatedColorLegend"), exports);
14
- (0, tslib_1.__exportStar)(require("./label"), exports);
15
- (0, tslib_1.__exportStar)(require("./legend"), exports);
16
- (0, tslib_1.__exportStar)(require("./plotGroup"), exports);
17
- (0, tslib_1.__exportStar)(require("./selectionBoxLayer"), exports);
18
- (0, tslib_1.__exportStar)(require("./table"), exports);
19
- (0, tslib_1.__exportStar)(require("./wrappedLabel"), exports);
20
- (0, tslib_1.__exportStar)(require("./xDragBoxLayer"), exports);
21
- (0, tslib_1.__exportStar)(require("./yDragBoxLayer"), exports);
8
+ tslib_1.__exportStar(require("./dragBoxLayer"), exports);
9
+ tslib_1.__exportStar(require("./dragLineLayer"), exports);
10
+ tslib_1.__exportStar(require("./gridlines"), exports);
11
+ tslib_1.__exportStar(require("./group"), exports);
12
+ tslib_1.__exportStar(require("./guideLineLayer"), exports);
13
+ tslib_1.__exportStar(require("./interpolatedColorLegend"), exports);
14
+ tslib_1.__exportStar(require("./label"), exports);
15
+ tslib_1.__exportStar(require("./legend"), exports);
16
+ tslib_1.__exportStar(require("./plotGroup"), exports);
17
+ tslib_1.__exportStar(require("./selectionBoxLayer"), exports);
18
+ tslib_1.__exportStar(require("./table"), exports);
19
+ tslib_1.__exportStar(require("./wrappedLabel"), exports);
20
+ tslib_1.__exportStar(require("./xDragBoxLayer"), exports);
21
+ tslib_1.__exportStar(require("./yDragBoxLayer"), exports);
@@ -12,7 +12,7 @@ var Formatters = require("../core/formatters");
12
12
  var Utils = require("../utils");
13
13
  var component_1 = require("./component");
14
14
  var InterpolatedColorLegend = /** @class */ (function (_super) {
15
- (0, tslib_1.__extends)(InterpolatedColorLegend, _super);
15
+ tslib_1.__extends(InterpolatedColorLegend, _super);
16
16
  /**
17
17
  * Creates an InterpolatedColorLegend.
18
18
  *
@@ -5,7 +5,7 @@
5
5
  import * as Typesettable from "typesettable";
6
6
  import { SimpleSelection, SpaceRequest } from "../core/interfaces";
7
7
  import { Component } from "./component";
8
- export declare type LabelFontSizePx = 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
8
+ export type LabelFontSizePx = 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
9
9
  export declare class Label extends Component {
10
10
  static _MIN_FONT_SIZE_PX: LabelFontSizePx;
11
11
  static _MAX_FONT_SIZE_PX: LabelFontSizePx;
@@ -9,7 +9,7 @@ var tslib_1 = require("tslib");
9
9
  var Typesettable = require("typesettable");
10
10
  var component_1 = require("./component");
11
11
  var Label = /** @class */ (function (_super) {
12
- (0, tslib_1.__extends)(Label, _super);
12
+ tslib_1.__extends(Label, _super);
13
13
  /**
14
14
  * A Label is a Component that displays a single line of text.
15
15
  *
@@ -130,7 +130,7 @@ var Label = /** @class */ (function (_super) {
130
130
  }(component_1.Component));
131
131
  exports.Label = Label;
132
132
  var TitleLabel = /** @class */ (function (_super) {
133
- (0, tslib_1.__extends)(TitleLabel, _super);
133
+ tslib_1.__extends(TitleLabel, _super);
134
134
  /**
135
135
  * @constructor
136
136
  * @param {string} [text]
@@ -146,7 +146,7 @@ var TitleLabel = /** @class */ (function (_super) {
146
146
  }(Label));
147
147
  exports.TitleLabel = TitleLabel;
148
148
  var AxisLabel = /** @class */ (function (_super) {
149
- (0, tslib_1.__extends)(AxisLabel, _super);
149
+ tslib_1.__extends(AxisLabel, _super);
150
150
  /**
151
151
  * @constructor
152
152
  * @param {string} [text]
@@ -180,7 +180,7 @@ var LegendTable = /** @class */ (function () {
180
180
  return LegendTable;
181
181
  }());
182
182
  var Legend = /** @class */ (function (_super) {
183
- (0, tslib_1.__extends)(Legend, _super);
183
+ tslib_1.__extends(Legend, _super);
184
184
  /**
185
185
  * The Legend consists of a series of entries, each with a color and label taken from the Color Scale.
186
186
  *
@@ -211,12 +211,20 @@ var Legend = /** @class */ (function (_super) {
211
211
  return _this;
212
212
  }
213
213
  Legend.prototype._setup = function () {
214
+ var _this = this;
214
215
  _super.prototype._setup.call(this);
215
- var fakeLegendRow = this.content().append("g").classed(Legend.LEGEND_ROW_CLASS, true);
216
+ // Keep the row out of content() except while measuring, since renderImmediately() clears content()
217
+ var fakeLegendRow = d3.create("svg:g").classed(Legend.LEGEND_ROW_CLASS, true);
216
218
  var fakeLegendEntry = fakeLegendRow.append("g").classed(Legend.LEGEND_ENTRY_CLASS, true);
217
219
  fakeLegendEntry.append("text");
218
220
  var context = new Typesettable.SvgContext(fakeLegendRow.node(), null, Configs.ADD_TITLE_ELEMENTS);
219
- this._measurer = new Typesettable.CacheMeasurer(context);
221
+ var ruler = context.createRuler();
222
+ this._measurer = new Typesettable.CacheMeasurer(function (text) {
223
+ _this.content().append(function () { return fakeLegendRow.node(); });
224
+ var dimensions = ruler(text);
225
+ fakeLegendRow.remove();
226
+ return dimensions;
227
+ });
220
228
  this._wrapper = new Typesettable.Wrapper().maxLines(this.maxLinesPerEntry());
221
229
  this._writer = new Typesettable.Writer(this._measurer, context, this._wrapper);
222
230
  };
@@ -366,12 +374,12 @@ var Legend = /** @class */ (function (_super) {
366
374
  var columnBounds = table.getColumnBounds(rowIndex, columnIndex);
367
375
  var withinColumn = Utils.Math.within(p, columnBounds);
368
376
  if (withinColumn) {
369
- var rowElement = _this.content().selectAll("." + Legend.LEGEND_ROW_CLASS).nodes()[rowIndex];
377
+ var rowElement = _this.content().selectAll(".".concat(Legend.LEGEND_ROW_CLASS)).nodes()[rowIndex];
370
378
  // HACKHACK The 2.x API chooses the symbol element as the "selection" to return, regardless of what
371
379
  // was actually selected
372
380
  var entryElement = d3.select(rowElement)
373
- .selectAll("." + Legend.LEGEND_ENTRY_CLASS).nodes()[Math.floor(columnIndex / 2)];
374
- var symbolElement = d3.select(entryElement).select("." + Legend.LEGEND_SYMBOL_CLASS);
381
+ .selectAll(".".concat(Legend.LEGEND_ENTRY_CLASS)).nodes()[Math.floor(columnIndex / 2)];
382
+ var symbolElement = d3.select(entryElement).select(".".concat(Legend.LEGEND_SYMBOL_CLASS));
375
383
  // HACKHACK The 2.x API returns the center {x, y} of the symbol as the position.
376
384
  var rowTranslate = Utils.DOM.getTranslateValues(d3.select(rowElement));
377
385
  var symbolTranslate = Utils.DOM.getTranslateValues(symbolElement);
@@ -404,7 +412,7 @@ var Legend = /** @class */ (function (_super) {
404
412
  rowsUpdate.exit().remove();
405
413
  rows.attr("transform", function (row, rowIndex) {
406
414
  var rowBounds = table.getRowBounds(rowIndex);
407
- return "translate(" + rowBounds.topLeft.x + ", " + rowBounds.topLeft.y + ")";
415
+ return "translate(".concat(rowBounds.topLeft.x, ", ").concat(rowBounds.topLeft.y, ")");
408
416
  });
409
417
  var self = this;
410
418
  rows.each(function (row, rowIndex) {
@@ -412,7 +420,7 @@ var Legend = /** @class */ (function (_super) {
412
420
  for (var i = 0; i < row.columns.length; i += 2) {
413
421
  symbolEntryPairs.push([row.columns[i], row.columns[i + 1]]);
414
422
  }
415
- var entriesUpdate = d3.select(this).selectAll("g." + Legend.LEGEND_ENTRY_CLASS).data(symbolEntryPairs);
423
+ var entriesUpdate = d3.select(this).selectAll("g.".concat(Legend.LEGEND_ENTRY_CLASS)).data(symbolEntryPairs);
416
424
  var entriesEnter = entriesUpdate
417
425
  .enter()
418
426
  .append("g")
@@ -427,7 +435,7 @@ var Legend = /** @class */ (function (_super) {
427
435
  var symbol = symbolEntryPair[0];
428
436
  var columnIndex = table.rows[rowIndex].columns.indexOf(symbol);
429
437
  var columnBounds = table.getColumnBounds(rowIndex, columnIndex);
430
- return "translate(" + (columnBounds.topLeft.x + symbol.width / 2) + ", " + symbol.height / 2 + ")";
438
+ return "translate(".concat(columnBounds.topLeft.x + symbol.width / 2, ", ").concat(symbol.height / 2, ")");
431
439
  })
432
440
  .attr("fill", function (symbolEntryPair) { return self._colorScale.scale(symbolEntryPair[0].data.name); })
433
441
  .attr("opacity", function (symbolEntryPair, _columnIndex) {
@@ -10,7 +10,7 @@ var plot_1 = require("../plots/plot");
10
10
  var Utils = require("../utils");
11
11
  var group_1 = require("./group");
12
12
  var PlotGroup = /** @class */ (function (_super) {
13
- (0, tslib_1.__extends)(PlotGroup, _super);
13
+ tslib_1.__extends(PlotGroup, _super);
14
14
  function PlotGroup() {
15
15
  return _super !== null && _super.apply(this, arguments) || this;
16
16
  }
@@ -12,9 +12,9 @@ var PropertyMode;
12
12
  (function (PropertyMode) {
13
13
  PropertyMode[PropertyMode["VALUE"] = 0] = "VALUE";
14
14
  PropertyMode[PropertyMode["PIXEL"] = 1] = "PIXEL";
15
- })(PropertyMode = exports.PropertyMode || (exports.PropertyMode = {}));
15
+ })(PropertyMode || (exports.PropertyMode = PropertyMode = {}));
16
16
  var SelectionBoxLayer = /** @class */ (function (_super) {
17
- (0, tslib_1.__extends)(SelectionBoxLayer, _super);
17
+ tslib_1.__extends(SelectionBoxLayer, _super);
18
18
  function SelectionBoxLayer() {
19
19
  var _this = _super.call(this) || this;
20
20
  _this._boxVisible = false;
@@ -10,7 +10,7 @@ var d3 = require("d3");
10
10
  var Utils = require("../utils");
11
11
  var componentContainer_1 = require("./componentContainer");
12
12
  var Table = /** @class */ (function (_super) {
13
- (0, tslib_1.__extends)(Table, _super);
13
+ tslib_1.__extends(Table, _super);
14
14
  /**
15
15
  * A Table combines Components in the form of a grid. A
16
16
  * common case is combining a y-axis, x-axis, and the plotted data via
@@ -9,7 +9,7 @@ var tslib_1 = require("tslib");
9
9
  var label_1 = require("./label");
10
10
  var DEFAULT_MAX_LINES = 2;
11
11
  var WrappedLabel = /** @class */ (function (_super) {
12
- (0, tslib_1.__extends)(WrappedLabel, _super);
12
+ tslib_1.__extends(WrappedLabel, _super);
13
13
  function WrappedLabel() {
14
14
  var _this = _super !== null && _super.apply(this, arguments) || this;
15
15
  _this._maxLines = DEFAULT_MAX_LINES;
@@ -8,7 +8,7 @@ exports.XDragBoxLayer = void 0;
8
8
  var tslib_1 = require("tslib");
9
9
  var dragBoxLayer_1 = require("./dragBoxLayer");
10
10
  var XDragBoxLayer = /** @class */ (function (_super) {
11
- (0, tslib_1.__extends)(XDragBoxLayer, _super);
11
+ tslib_1.__extends(XDragBoxLayer, _super);
12
12
  /**
13
13
  * An XDragBoxLayer is a DragBoxLayer whose size can only be set in the X-direction.
14
14
  * The y-values of the bounds() are always set to 0 and the height() of the XDragBoxLayer.
@@ -8,7 +8,7 @@ exports.YDragBoxLayer = void 0;
8
8
  var tslib_1 = require("tslib");
9
9
  var dragBoxLayer_1 = require("./dragBoxLayer");
10
10
  var YDragBoxLayer = /** @class */ (function (_super) {
11
- (0, tslib_1.__extends)(YDragBoxLayer, _super);
11
+ tslib_1.__extends(YDragBoxLayer, _super);
12
12
  /**
13
13
  * A YDragBoxLayer is a DragBoxLayer whose size can only be set in the Y-direction.
14
14
  * The x-values of the bounds() are always set to 0 and the width() of the YDragBoxLayer.
@@ -2,7 +2,7 @@
2
2
  * Copyright 2014-present Palantir Technologies
3
3
  * @license MIT
4
4
  */
5
- export declare type DatasetCallback = (dataset: Dataset) => void;
5
+ export type DatasetCallback = (dataset: Dataset) => void;
6
6
  export declare class Dataset {
7
7
  private _data;
8
8
  private _metadata;
@@ -10,7 +10,7 @@ import { Dataset } from "./dataset";
10
10
  * The value will be different for each use of the formatter - check the documentation of individual
11
11
  * methods to see what will be passed into the formatter.
12
12
  */
13
- export declare type Formatter = (value: any) => string;
13
+ export type Formatter = (value: any) => string;
14
14
  /**
15
15
  * A formatter function that will be passed the value to format as well as the underlying datum, index, and
16
16
  * dataset that the value came from. Datum-backed visual elements that display labels, such as Bar Plot bars
@@ -19,7 +19,7 @@ export declare type Formatter = (value: any) => string;
19
19
  * The value will be different for each use of the formatter - check the documentation of individual
20
20
  * methods to see what will be passed into the formatter.
21
21
  */
22
- export declare type DatumFormatter = (value: any, datum: any, index: number, dataset: Dataset) => string;
22
+ export type DatumFormatter = (value: any, datum: any, index: number, dataset: Dataset) => string;
23
23
  /**
24
24
  * Creates a formatter for currency values.
25
25
  *