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
@@ -11,7 +11,7 @@ var Utils = require("../utils");
11
11
  var deferredRenderer_1 = require("./deferredRenderer");
12
12
  var plot_1 = require("./plot");
13
13
  var XYPlot = /** @class */ (function (_super) {
14
- (0, tslib_1.__extends)(XYPlot, _super);
14
+ tslib_1.__extends(XYPlot, _super);
15
15
  /**
16
16
  * An XYPlot is a Plot that displays data along two primary directions, X and Y.
17
17
  *
@@ -29,10 +29,10 @@ var XYPlot = /** @class */ (function (_super) {
29
29
  return;
30
30
  }
31
31
  if (_this._renderArea != null) {
32
- _this._renderArea.attr("transform", "translate(" + tx + ", " + ty + ") scale(" + sx + ", " + sy + ")");
32
+ _this._renderArea.attr("transform", "translate(".concat(tx, ", ").concat(ty, ") scale(").concat(sx, ", ").concat(sy, ")"));
33
33
  }
34
34
  if (_this._canvas != null) {
35
- _this._canvas.style("transform", "translate(" + tx + "px, " + ty + "px) scale(" + sx + ", " + sy + ")");
35
+ _this._canvas.style("transform", "translate(".concat(tx, "px, ").concat(ty, "px) scale(").concat(sx, ", ").concat(sy, ")"));
36
36
  }
37
37
  };
38
38
  _this.addClass("xy-plot");
@@ -196,6 +196,7 @@ var XYPlot = /** @class */ (function (_super) {
196
196
  yScale.range([this.height(), 0]);
197
197
  }
198
198
  }
199
+ this._updateExtents();
199
200
  return this;
200
201
  };
201
202
  XYPlot.prototype._updateXExtentsAndAutodomain = function () {
@@ -22,6 +22,7 @@ export declare class Category extends Scale<string, number> implements ITransfor
22
22
  */
23
23
  private _d3TransformationScale;
24
24
  private _d3Scale;
25
+ private _domain;
25
26
  private _range;
26
27
  private _innerPadding;
27
28
  private _outerPadding;
@@ -12,7 +12,7 @@ var Utils = require("../utils");
12
12
  var scale_1 = require("./scale");
13
13
  var TRANSFORMATION_SPACE = [0, 1];
14
14
  var Category = /** @class */ (function (_super) {
15
- (0, tslib_1.__extends)(Category, _super);
15
+ tslib_1.__extends(Category, _super);
16
16
  /**
17
17
  * A Category Scale maps strings to numbers.
18
18
  *
@@ -20,10 +20,11 @@ var Category = /** @class */ (function (_super) {
20
20
  */
21
21
  function Category() {
22
22
  var _this = _super.call(this) || this;
23
+ _this._domain = [];
23
24
  _this._range = [0, 1];
24
25
  _this._d3Scale = d3.scaleBand();
25
26
  _this._d3Scale.range(TRANSFORMATION_SPACE);
26
- _this._d3TransformationScale = d3.scaleLinear();
27
+ _this._d3TransformationScale = d3.scaleLinear().unknown(NaN);
27
28
  _this._d3TransformationScale.domain(TRANSFORMATION_SPACE);
28
29
  var d3InnerPadding = 0.3;
29
30
  _this._innerPadding = Category._convertToPlottableInnerPadding(d3InnerPadding);
@@ -69,7 +70,7 @@ var Category = /** @class */ (function (_super) {
69
70
  var normalizedDomain = domain.map(function (d) { return _this._d3Scale(d) + rangeBand / 2; });
70
71
  var domainStart = d3.bisect(normalizedDomain, domainStartNormalized);
71
72
  var domainEnd = d3.bisect(normalizedDomain, domainEndNormalized);
72
- return domain.slice(domainStart, domainEnd);
73
+ return this._domain.slice(domainStart, domainEnd);
73
74
  };
74
75
  Category.prototype.range = function (values) {
75
76
  return _super.prototype.range.call(this, values);
@@ -127,8 +128,9 @@ var Category = /** @class */ (function (_super) {
127
128
  return this;
128
129
  };
129
130
  Category.prototype.scale = function (value) {
131
+ // Accessors read untyped data, so values can be numbers, and 1 and "1" must share a band
130
132
  // Determine the middle of the range band for the value
131
- var untransformed = this._d3Scale(value) + this._d3Scale.bandwidth() / 2;
133
+ var untransformed = this._d3Scale(String(value)) + this._d3Scale.bandwidth() / 2;
132
134
  // Convert to screen space
133
135
  return this._d3TransformationScale(untransformed);
134
136
  };
@@ -169,10 +171,11 @@ var Category = /** @class */ (function (_super) {
169
171
  };
170
172
  Category.prototype._backingScaleDomain = function (values) {
171
173
  if (values == null) {
172
- return this._d3Scale.domain();
174
+ return this._domain.slice();
173
175
  }
174
176
  else {
175
- this._d3Scale.domain(values);
177
+ this._domain = Utils.Array.uniq(values);
178
+ this._d3Scale.domain(this._domain.map(String));
176
179
  this._setBands();
177
180
  return this;
178
181
  }
@@ -7,9 +7,9 @@ export declare class Color extends Scale<string, string> {
7
7
  private static _LOOP_LIGHTEN_FACTOR;
8
8
  private static _MAXIMUM_COLORS_FROM_CSS;
9
9
  private static _plottableColorCache;
10
- private _d3Scale;
11
- private _rangeLength;
12
- private _tracker;
10
+ private _domain;
11
+ private _domainIndices;
12
+ private _range;
13
13
  /**
14
14
  * A Color Scale maps string values to color hex values expressed as a string.
15
15
  *
@@ -33,6 +33,7 @@ export declare class Color extends Scale<string, string> {
33
33
  * @returns {string}
34
34
  */
35
35
  scale(value: string): string;
36
+ private _domainIndex;
36
37
  protected _getDomain(): string[];
37
38
  protected _backingScaleDomain(): string[];
38
39
  protected _backingScaleDomain(values: string[]): this;
@@ -9,43 +9,27 @@ var tslib_1 = require("tslib");
9
9
  var d3 = require("d3");
10
10
  var Utils = require("../utils");
11
11
  var scale_1 = require("./scale");
12
- /**
13
- * Workaround for bad d3 behavior.
14
- *
15
- * d3's color scales, which are oridinal scales, have side-effects when invoked.
16
- * When you call the `scale(value)` as a function, it will implicitly add new
17
- * values to the domain.
18
- *
19
- * These side-effects cause us to rely on looking up the current scale state
20
- * with the `.domain()` and `.range()` methods. However, these methods have poor
21
- * performance implications since they will always slice their internal values
22
- * before returning. Inside the inner render loop of color scatter plot points,
23
- * these slices add up.
24
- */
25
- var ImplicitSeriesTracker = /** @class */ (function () {
26
- function ImplicitSeriesTracker() {
27
- this.count = 0;
28
- this.tracker = {};
29
- }
30
- ImplicitSeriesTracker.prototype.getIndex = function (value) {
31
- if (this.tracker[value] != null) {
32
- return this.tracker[value];
33
- }
34
- else {
35
- var idx = this.count;
36
- this.tracker[value] = idx;
37
- this.count += 1;
38
- return idx;
39
- }
40
- };
41
- ImplicitSeriesTracker.prototype.clear = function () {
42
- this.count = 0;
43
- this.tracker = {};
44
- };
45
- return ImplicitSeriesTracker;
46
- }());
12
+ // Preserve the public D3 4 palette names removed in D3 5.
13
+ var CATEGORY20 = [
14
+ "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
15
+ "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5",
16
+ "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f",
17
+ "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5",
18
+ ];
19
+ var CATEGORY20B = [
20
+ "#393b79", "#5254a3", "#6b6ecf", "#9c9ede", "#637939",
21
+ "#8ca252", "#b5cf6b", "#cedb9c", "#8c6d31", "#bd9e39",
22
+ "#e7ba52", "#e7cb94", "#843c39", "#ad494a", "#d6616b",
23
+ "#e7969c", "#7b4173", "#a55194", "#ce6dbd", "#de9ed6",
24
+ ];
25
+ var CATEGORY20C = [
26
+ "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d",
27
+ "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476",
28
+ "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc",
29
+ "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9",
30
+ ];
47
31
  var Color = /** @class */ (function (_super) {
48
- (0, tslib_1.__extends)(Color, _super);
32
+ tslib_1.__extends(Color, _super);
49
33
  /**
50
34
  * A Color Scale maps string values to color hex values expressed as a string.
51
35
  *
@@ -56,43 +40,41 @@ var Color = /** @class */ (function (_super) {
56
40
  */
57
41
  function Color(scaleType) {
58
42
  var _this = _super.call(this) || this;
59
- // Cache the number of range value to avoid calling `scale.range().length`
60
- _this._rangeLength = 1;
61
- _this._tracker = new ImplicitSeriesTracker();
62
- var scale;
43
+ _this._domain = [];
44
+ _this._domainIndices = new Map();
45
+ var range;
63
46
  switch (scaleType) {
64
47
  case null:
65
48
  case undefined:
66
49
  if (Color._plottableColorCache == null) {
67
50
  Color._plottableColorCache = Color._getPlottableColors();
68
51
  }
69
- scale = d3.scaleOrdinal().range(Color._plottableColorCache);
52
+ range = Color._plottableColorCache;
70
53
  break;
71
54
  case "Category10":
72
55
  case "category10":
73
56
  case "10":
74
- scale = d3.scaleOrdinal(d3.schemeCategory10);
57
+ range = d3.schemeCategory10;
75
58
  break;
76
59
  case "Category20":
77
60
  case "category20":
78
61
  case "20":
79
- scale = d3.scaleOrdinal(d3.schemeCategory20);
62
+ range = CATEGORY20;
80
63
  break;
81
64
  case "Category20b":
82
65
  case "category20b":
83
66
  case "20b":
84
- scale = d3.scaleOrdinal(d3.schemeCategory20b);
67
+ range = CATEGORY20B;
85
68
  break;
86
69
  case "Category20c":
87
70
  case "category20c":
88
71
  case "20c":
89
- scale = d3.scaleOrdinal(d3.schemeCategory20c);
72
+ range = CATEGORY20C;
90
73
  break;
91
74
  default:
92
75
  throw new Error("Unsupported ColorScale type");
93
76
  }
94
- _this._d3Scale = scale;
95
- _this._rangeLength = _this._d3Scale.range().length;
77
+ _this._range = range.slice();
96
78
  return _this;
97
79
  }
98
80
  Color.prototype.extentOfValues = function (values) {
@@ -117,7 +99,7 @@ var Color = /** @class */ (function (_super) {
117
99
  }
118
100
  plottableDefaultColors.push(colorHex);
119
101
  i++;
120
- colorHex = Utils.Color.colorTest(colorTester, "plottable-colors-" + i);
102
+ colorHex = Utils.Color.colorTest(colorTester, "plottable-colors-".concat(i));
121
103
  }
122
104
  colorTester.remove();
123
105
  return plottableDefaultColors;
@@ -132,34 +114,45 @@ var Color = /** @class */ (function (_super) {
132
114
  * @returns {string}
133
115
  */
134
116
  Color.prototype.scale = function (value) {
135
- var color = this._d3Scale(value);
136
- var index = this._tracker.getIndex(value);
137
- var numLooped = Math.floor(index / this._rangeLength);
117
+ var index = this._domainIndex(value);
118
+ var color = this._range[index % this._range.length];
119
+ var numLooped = Math.floor(index / this._range.length);
138
120
  if (numLooped === 0) {
139
121
  return color;
140
122
  }
141
123
  var modifyFactor = Math.log(numLooped * Color._LOOP_LIGHTEN_FACTOR + 1);
142
124
  return Utils.Color.lightenColor(color, modifyFactor);
143
125
  };
126
+ Color.prototype._domainIndex = function (value) {
127
+ // Accessors read untyped data, so values can be numbers, and 1 and "1" must share a color
128
+ var key = String(value);
129
+ var index = this._domainIndices.get(key);
130
+ if (index == null) {
131
+ index = this._domain.push(value) - 1;
132
+ this._domainIndices.set(key, index);
133
+ }
134
+ return index;
135
+ };
144
136
  Color.prototype._getDomain = function () {
145
137
  return this._backingScaleDomain();
146
138
  };
147
139
  Color.prototype._backingScaleDomain = function (values) {
140
+ var _this = this;
148
141
  if (values == null) {
149
- return this._d3Scale.domain();
142
+ return this._domain.slice();
150
143
  }
151
144
  else {
152
- this._d3Scale.domain(values);
153
- this._tracker.clear();
145
+ this._domain = [];
146
+ this._domainIndices.clear();
147
+ values.forEach(function (value) { return _this._domainIndex(value); });
154
148
  return this;
155
149
  }
156
150
  };
157
151
  Color.prototype._getRange = function () {
158
- return this._d3Scale.range();
152
+ return this._range.slice();
159
153
  };
160
154
  Color.prototype._setRange = function (values) {
161
- this._d3Scale.range(values);
162
- this._rangeLength = values.length;
155
+ this._range = values.slice();
163
156
  };
164
157
  Color._LOOP_LIGHTEN_FACTOR = 1.6;
165
158
  // The maximum number of colors we are getting from CSS stylesheets
@@ -4,17 +4,18 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isTransformable = exports.TickGenerators = void 0;
7
+ exports.TickGenerators = void 0;
8
+ exports.isTransformable = isTransformable;
8
9
  var tslib_1 = require("tslib");
9
10
  var TickGenerators = require("./tickGenerators");
10
11
  exports.TickGenerators = TickGenerators;
11
- (0, tslib_1.__exportStar)(require("./categoryScale"), exports);
12
- (0, tslib_1.__exportStar)(require("./colorScale"), exports);
13
- (0, tslib_1.__exportStar)(require("./interpolatedColorScale"), exports);
14
- (0, tslib_1.__exportStar)(require("./linearScale"), exports);
15
- (0, tslib_1.__exportStar)(require("./logScale"), exports);
16
- (0, tslib_1.__exportStar)(require("./modifiedLogScale"), exports);
17
- (0, tslib_1.__exportStar)(require("./timeScale"), exports);
12
+ tslib_1.__exportStar(require("./categoryScale"), exports);
13
+ tslib_1.__exportStar(require("./colorScale"), exports);
14
+ tslib_1.__exportStar(require("./interpolatedColorScale"), exports);
15
+ tslib_1.__exportStar(require("./linearScale"), exports);
16
+ tslib_1.__exportStar(require("./logScale"), exports);
17
+ tslib_1.__exportStar(require("./modifiedLogScale"), exports);
18
+ tslib_1.__exportStar(require("./timeScale"), exports);
18
19
  // ---------------------------------------------------------
19
20
  var categoryScale_1 = require("./categoryScale");
20
21
  var quantitativeScale_1 = require("./quantitativeScale");
@@ -28,4 +29,3 @@ function isTransformable(scale) {
28
29
  return (scale instanceof quantitativeScale_1.QuantitativeScale ||
29
30
  scale instanceof categoryScale_1.Category);
30
31
  }
31
- exports.isTransformable = isTransformable;
@@ -9,8 +9,9 @@ var tslib_1 = require("tslib");
9
9
  var d3 = require("d3");
10
10
  var Utils = require("../utils");
11
11
  var scale_1 = require("./scale");
12
+ var UNKNOWN_COLOR = "rgb(0, 0, 0)";
12
13
  var InterpolatedColor = /** @class */ (function (_super) {
13
- (0, tslib_1.__extends)(InterpolatedColor, _super);
14
+ tslib_1.__extends(InterpolatedColor, _super);
14
15
  /**
15
16
  * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings.
16
17
  *
@@ -21,16 +22,16 @@ var InterpolatedColor = /** @class */ (function (_super) {
21
22
  var _this = _super.call(this) || this;
22
23
  switch (scaleType) {
23
24
  case "linear":
24
- _this._colorScale = d3.scaleLinear();
25
+ _this._colorScale = d3.scaleLinear().unknown(UNKNOWN_COLOR);
25
26
  break;
26
27
  case "log":
27
- _this._colorScale = d3.scaleLog();
28
+ _this._colorScale = d3.scaleLog().unknown(UNKNOWN_COLOR);
28
29
  break;
29
30
  case "sqrt":
30
- _this._colorScale = d3.scaleSqrt();
31
+ _this._colorScale = d3.scaleSqrt().unknown(UNKNOWN_COLOR);
31
32
  break;
32
33
  case "pow":
33
- _this._colorScale = d3.scalePow();
34
+ _this._colorScale = d3.scalePow().unknown(UNKNOWN_COLOR);
34
35
  break;
35
36
  }
36
37
  if (_this._colorScale == null) {
@@ -90,7 +91,7 @@ var InterpolatedColor = /** @class */ (function (_super) {
90
91
  return this;
91
92
  };
92
93
  InterpolatedColor.prototype.scale = function (value) {
93
- return this._d3Scale(value);
94
+ return this._d3Scale(+value);
94
95
  };
95
96
  InterpolatedColor.prototype._getDomain = function () {
96
97
  return this._backingScaleDomain();
@@ -112,7 +113,7 @@ var InterpolatedColor = /** @class */ (function (_super) {
112
113
  this._resetScale();
113
114
  };
114
115
  InterpolatedColor.REDS = [
115
- "#FFFFFF",
116
+ "#FFFFFF", // white
116
117
  "#FFF6E1",
117
118
  "#FEF4C0",
118
119
  "#FED976",
@@ -123,7 +124,7 @@ var InterpolatedColor = /** @class */ (function (_super) {
123
124
  "#B10026", // red
124
125
  ];
125
126
  InterpolatedColor.BLUES = [
126
- "#FFFFFF",
127
+ "#FFFFFF", // white
127
128
  "#CCFFFF",
128
129
  "#A5FFFD",
129
130
  "#85F7FB",
@@ -134,7 +135,7 @@ var InterpolatedColor = /** @class */ (function (_super) {
134
135
  "#0B02E1", // blue
135
136
  ];
136
137
  InterpolatedColor.POSNEG = [
137
- "#0B02E1",
138
+ "#0B02E1", // blue
138
139
  "#2545D3",
139
140
  "#417FD0",
140
141
  "#55A7E0",
@@ -142,7 +143,7 @@ var InterpolatedColor = /** @class */ (function (_super) {
142
143
  "#85F7FB",
143
144
  "#A5FFFD",
144
145
  "#CCFFFF",
145
- "#FFFFFF",
146
+ "#FFFFFF", // white
146
147
  "#FFF6E1",
147
148
  "#FEF4C0",
148
149
  "#FED976",
@@ -9,13 +9,13 @@ var tslib_1 = require("tslib");
9
9
  var d3 = require("d3");
10
10
  var quantitativeScale_1 = require("./quantitativeScale");
11
11
  var Linear = /** @class */ (function (_super) {
12
- (0, tslib_1.__extends)(Linear, _super);
12
+ tslib_1.__extends(Linear, _super);
13
13
  /**
14
14
  * @constructor
15
15
  */
16
16
  function Linear() {
17
17
  var _this = _super.call(this) || this;
18
- _this._d3Scale = d3.scaleLinear();
18
+ _this._d3Scale = d3.scaleLinear().unknown(NaN);
19
19
  return _this;
20
20
  }
21
21
  Linear.prototype._defaultExtent = function () {
@@ -28,7 +28,7 @@ var Linear = /** @class */ (function (_super) {
28
28
  return singleValueDomain;
29
29
  };
30
30
  Linear.prototype.scale = function (value) {
31
- return this._d3Scale(value);
31
+ return this._d3Scale(+value);
32
32
  };
33
33
  Linear.prototype.scaleTransformation = function (value) {
34
34
  return this.scale(value);
@@ -9,14 +9,14 @@ var tslib_1 = require("tslib");
9
9
  var d3 = require("d3");
10
10
  var quantitativeScale_1 = require("./quantitativeScale");
11
11
  var Log = /** @class */ (function (_super) {
12
- (0, tslib_1.__extends)(Log, _super);
12
+ tslib_1.__extends(Log, _super);
13
13
  /**
14
14
  * @constructor
15
15
  */
16
16
  function Log(base) {
17
17
  if (base === void 0) { base = 10; }
18
18
  var _this = _super.call(this) || this;
19
- _this._d3Scale = d3.scaleLog().base(base);
19
+ _this._d3Scale = d3.scaleLog().base(base).unknown(NaN);
20
20
  _this._setDomain(_this._defaultExtent());
21
21
  return _this;
22
22
  }
@@ -31,7 +31,7 @@ var Log = /** @class */ (function (_super) {
31
31
  return singleValueDomain;
32
32
  };
33
33
  Log.prototype.scale = function (value) {
34
- return this._d3Scale(value);
34
+ return this._d3Scale(+value);
35
35
  };
36
36
  Log.prototype.scaleTransformation = function (value) {
37
37
  return this.scale(value);
@@ -11,7 +11,7 @@ var Utils = require("../utils");
11
11
  var Scales = require("./");
12
12
  var quantitativeScale_1 = require("./quantitativeScale");
13
13
  var ModifiedLog = /** @class */ (function (_super) {
14
- (0, tslib_1.__extends)(ModifiedLog, _super);
14
+ tslib_1.__extends(ModifiedLog, _super);
15
15
  /**
16
16
  * A ModifiedLog Scale acts as a regular log scale for large numbers.
17
17
  * As it approaches 0, it gradually becomes linear.
@@ -66,7 +66,7 @@ var ModifiedLog = /** @class */ (function (_super) {
66
66
  }
67
67
  return ticks;
68
68
  };
69
- _this._d3Scale = d3.scaleLinear();
69
+ _this._d3Scale = d3.scaleLinear().unknown(NaN);
70
70
  _this._base = base;
71
71
  _this._pivot = _this._base;
72
72
  _this._setDomain(_this._defaultExtent());
@@ -11,7 +11,7 @@ var panZoomConstraints_1 = require("../interactions/panZoomConstraints");
11
11
  var Utils = require("../utils");
12
12
  var scale_1 = require("./scale");
13
13
  var QuantitativeScale = /** @class */ (function (_super) {
14
- (0, tslib_1.__extends)(QuantitativeScale, _super);
14
+ tslib_1.__extends(QuantitativeScale, _super);
15
15
  /**
16
16
  * A QuantitativeScale is a Scale that maps number-like values to numbers.
17
17
  * It is invertible and continuous.
@@ -3,7 +3,7 @@
3
3
  * @license MIT
4
4
  */
5
5
  import * as Scales from "./";
6
- export declare type TransformableScale<D, R> = Scale<D, R> & Scales.ITransformableScale;
6
+ export type TransformableScale<D, R> = Scale<D, R> & Scales.ITransformableScale;
7
7
  export interface IScaleCallback<S extends Scale<any, any>> {
8
8
  (scale: S): any;
9
9
  }
@@ -4,7 +4,8 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.integerTickGenerator = exports.intervalTickGenerator = void 0;
7
+ exports.intervalTickGenerator = intervalTickGenerator;
8
+ exports.integerTickGenerator = integerTickGenerator;
8
9
  var Utils = require("../utils");
9
10
  /**
10
11
  * Creates a TickGenerator using the specified interval.
@@ -30,7 +31,6 @@ function intervalTickGenerator(interval) {
30
31
  return lowTicks.concat(middleTicks).concat(highTicks);
31
32
  };
32
33
  }
33
- exports.intervalTickGenerator = intervalTickGenerator;
34
34
  /**
35
35
  * Creates a TickGenerator returns only integer tick values.
36
36
  *
@@ -42,4 +42,3 @@ function integerTickGenerator() {
42
42
  return defaultTicks.filter(function (tick, i) { return (tick % 1 === 0) || (i === 0) || (i === defaultTicks.length - 1); });
43
43
  };
44
44
  }
45
- exports.integerTickGenerator = integerTickGenerator;
@@ -10,7 +10,7 @@ var d3 = require("d3");
10
10
  var timeAxis_1 = require("../axes/timeAxis");
11
11
  var quantitativeScale_1 = require("./quantitativeScale");
12
12
  var Time = /** @class */ (function (_super) {
13
- (0, tslib_1.__extends)(Time, _super);
13
+ tslib_1.__extends(Time, _super);
14
14
  /**
15
15
  * A Time Scale maps Date objects to numbers.
16
16
  *
@@ -18,7 +18,7 @@ var Time = /** @class */ (function (_super) {
18
18
  */
19
19
  function Time() {
20
20
  var _this = _super.call(this) || this;
21
- _this._d3Scale = d3.scaleTime();
21
+ _this._d3Scale = d3.scaleTime().unknown(NaN);
22
22
  _this.autoDomain();
23
23
  return _this;
24
24
  }
@@ -33,7 +33,7 @@ var Time = /** @class */ (function (_super) {
33
33
  if (step === void 0) { step = 1; }
34
34
  if (useUTC === void 0) { useUTC = false; }
35
35
  // temporarily creats a time scale from our linear scale into a time scale so we can get access to its api
36
- var tempScale = d3.scaleTime();
36
+ var tempScale = d3.scaleTime().unknown(NaN);
37
37
  var d3Interval = Time.timeIntervalToD3Time(interval, useUTC).every(step);
38
38
  tempScale.domain(this.domain());
39
39
  tempScale.range(this.range());
@@ -61,7 +61,7 @@ var Time = /** @class */ (function (_super) {
61
61
  return singleValueDomain;
62
62
  };
63
63
  Time.prototype.scale = function (value) {
64
- return this._d3Scale(value);
64
+ return this._d3Scale(+value);
65
65
  };
66
66
  Time.prototype.scaleTransformation = function (value) {
67
67
  return this.scale(new Date(value));
@@ -4,8 +4,10 @@
4
4
  * @license MIT
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createFilledArray = exports.flatten = exports.uniq = exports.add = void 0;
8
- var d3 = require("d3");
7
+ exports.add = add;
8
+ exports.uniq = uniq;
9
+ exports.flatten = flatten;
10
+ exports.createFilledArray = createFilledArray;
9
11
  var nativeArray = window.Array;
10
12
  /**
11
13
  * Takes two arrays of numbers and adds them together
@@ -20,7 +22,6 @@ function add(aList, bList) {
20
22
  }
21
23
  return aList.map(function (_, i) { return aList[i] + bList[i]; });
22
24
  }
23
- exports.add = add;
24
25
  /**
25
26
  * Take an array of values, and return the unique values.
26
27
  * Will work iff ∀ a, b, a.toString() == b.toString() => a == b; will break on Object inputs
@@ -29,7 +30,7 @@ exports.add = add;
29
30
  * @return {T[]} The unique values
30
31
  */
31
32
  function uniq(arr) {
32
- var seen = d3.set();
33
+ var seen = new Set();
33
34
  var result = [];
34
35
  arr.forEach(function (x) {
35
36
  if (!seen.has(String(x))) {
@@ -39,7 +40,6 @@ function uniq(arr) {
39
40
  });
40
41
  return result;
41
42
  }
42
- exports.uniq = uniq;
43
43
  /**
44
44
  * @param {T[][]} a The 2D array that will have its elements joined together.
45
45
  * @return {T[]} Every array in a, concatenated together in the order they appear.
@@ -47,7 +47,6 @@ exports.uniq = uniq;
47
47
  function flatten(a) {
48
48
  return nativeArray.prototype.concat.apply([], a);
49
49
  }
50
- exports.flatten = flatten;
51
50
  /**
52
51
  * Creates an array of length `count`, filled with value or (if value is a function), value()
53
52
  *
@@ -62,4 +61,3 @@ function createFilledArray(value, count) {
62
61
  }
63
62
  return out;
64
63
  }
65
- exports.createFilledArray = createFilledArray;
@@ -13,7 +13,7 @@ var set_1 = require("./set");
13
13
  * All callbacks should have the same signature.
14
14
  */
15
15
  var CallbackSet = /** @class */ (function (_super) {
16
- (0, tslib_1.__extends)(CallbackSet, _super);
16
+ tslib_1.__extends(CallbackSet, _super);
17
17
  function CallbackSet() {
18
18
  return _super !== null && _super.apply(this, arguments) || this;
19
19
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coerceExternalD3 = void 0;
3
+ exports.coerceExternalD3 = coerceExternalD3;
4
4
  var d3 = require("d3");
5
5
  /**
6
6
  * Coerce possibly external d3 instance into our own instance of d3 so we can use d3-selection-multi.
@@ -28,4 +28,3 @@ function coerceExternalD3(externalD3Selection) {
28
28
  return externalD3Selection;
29
29
  }
30
30
  }
31
- exports.coerceExternalD3 = coerceExternalD3;