plottable 4.0.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.
- package/build/src/components/legend.js +10 -2
- package/build/src/core/version.js +1 -1
- package/build/src/dispatchers/dispatcher.js +8 -1
- package/build/src/interactions/clickInteraction.js +7 -0
- package/build/src/interactions/dragInteraction.js +6 -0
- package/build/src/interactions/interaction.d.ts +2 -1
- package/build/src/interactions/interaction.js +11 -1
- package/build/src/interactions/keyInteraction.js +7 -0
- package/build/src/interactions/panZoomInteraction.js +6 -0
- package/build/src/interactions/pointerInteraction.js +7 -0
- package/build/src/plots/barPlot.d.ts +6 -0
- package/build/src/plots/barPlot.js +12 -0
- package/build/src/plots/piePlot.js +1 -0
- package/build/src/plots/plot.d.ts +2 -0
- package/build/src/plots/plot.js +3 -1
- package/build/src/plots/rectanglePlot.d.ts +5 -0
- package/build/src/plots/rectanglePlot.js +11 -0
- package/build/src/plots/scatterPlot.d.ts +11 -0
- package/build/src/plots/scatterPlot.js +27 -0
- package/build/src/plots/xyPlot.js +1 -0
- package/build/src/scales/categoryScale.d.ts +1 -0
- package/build/src/scales/categoryScale.js +7 -4
- package/build/src/scales/colorScale.d.ts +4 -3
- package/build/src/scales/colorScale.js +29 -55
- package/build/src/scales/interpolatedColorScale.js +5 -4
- package/build/src/utils/entityStore.d.ts +6 -3
- package/build/src/utils/rTree.d.ts +11 -2
- package/build/src/utils/rTree.js +15 -3
- package/build/src/utils/stackingUtils.js +34 -0
- package/package.json +4 -4
- package/plottable.css +4 -3
- package/plottable.js +209 -73
- package/plottable.js.map +1 -1
package/plottable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Plottable 4.
|
|
2
|
+
* Plottable 4.1.0 (https://github.com/palantir/plottable)
|
|
3
3
|
* Copyright 2014-2017 Palantir Technologies
|
|
4
4
|
* Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -522,7 +522,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
522
522
|
};
|
|
523
523
|
Plot.prototype.setBounds = function (width, height, originX, originY) {
|
|
524
524
|
_super.prototype.setBounds.call(this, width, height, originX, originY);
|
|
525
|
-
this.
|
|
525
|
+
this._resetEntityStore();
|
|
526
526
|
if (this._canvas != null) {
|
|
527
527
|
if (this._bufferCanvas && !this._bufferCanvasValid) {
|
|
528
528
|
// copy current canvas to buffer 1:1
|
|
@@ -1087,6 +1087,8 @@ var Plot = /** @class */ (function (_super) {
|
|
|
1087
1087
|
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
1088
1088
|
* or undefined if no {Plots.PlotEntity} can be found.
|
|
1089
1089
|
*
|
|
1090
|
+
* If several Entities are equally near, returns the one drawn last (the last Dataset, then the last datum).
|
|
1091
|
+
*
|
|
1090
1092
|
* @param {Point} queryPoint
|
|
1091
1093
|
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
1092
1094
|
*/
|
|
@@ -2733,7 +2735,15 @@ exports.Interaction = void 0;
|
|
|
2733
2735
|
var Interaction = /** @class */ (function () {
|
|
2734
2736
|
function Interaction() {
|
|
2735
2737
|
var _this = this;
|
|
2736
|
-
this._anchorCallback = function (component) {
|
|
2738
|
+
this._anchorCallback = function (component) {
|
|
2739
|
+
_this._detachCallback();
|
|
2740
|
+
_this._anchor(component);
|
|
2741
|
+
};
|
|
2742
|
+
this._detachCallback = function () {
|
|
2743
|
+
if (_this._isAnchored) {
|
|
2744
|
+
_this._unanchor();
|
|
2745
|
+
}
|
|
2746
|
+
};
|
|
2737
2747
|
this._enabled = true;
|
|
2738
2748
|
}
|
|
2739
2749
|
/**
|
|
@@ -2812,6 +2822,7 @@ var Interaction = /** @class */ (function () {
|
|
|
2812
2822
|
Interaction.prototype._connect = function () {
|
|
2813
2823
|
if (this.enabled() && this._componentAttachedTo != null && !this._isAnchored) {
|
|
2814
2824
|
this._componentAttachedTo.onAnchor(this._anchorCallback);
|
|
2825
|
+
this._componentAttachedTo.onDetach(this._detachCallback);
|
|
2815
2826
|
}
|
|
2816
2827
|
};
|
|
2817
2828
|
Interaction.prototype._disconnect = function () {
|
|
@@ -2820,6 +2831,7 @@ var Interaction = /** @class */ (function () {
|
|
|
2820
2831
|
}
|
|
2821
2832
|
if (this._componentAttachedTo != null) {
|
|
2822
2833
|
this._componentAttachedTo.offAnchor(this._anchorCallback);
|
|
2834
|
+
this._componentAttachedTo.offDetach(this._detachCallback);
|
|
2823
2835
|
}
|
|
2824
2836
|
};
|
|
2825
2837
|
return Interaction;
|
|
@@ -3030,6 +3042,7 @@ var XYPlot = /** @class */ (function (_super) {
|
|
|
3030
3042
|
yScale.range([this.height(), 0]);
|
|
3031
3043
|
}
|
|
3032
3044
|
}
|
|
3045
|
+
this._updateExtents();
|
|
3033
3046
|
return this;
|
|
3034
3047
|
};
|
|
3035
3048
|
XYPlot.prototype._updateXExtentsAndAutodomain = function () {
|
|
@@ -4487,7 +4500,14 @@ var Dispatcher = /** @class */ (function () {
|
|
|
4487
4500
|
}
|
|
4488
4501
|
var callbackSet = this._eventNameToCallbackSet[eventName];
|
|
4489
4502
|
if (callbackSet != null) {
|
|
4490
|
-
|
|
4503
|
+
// Interactions can resubscribe while handling an event, which Set.forEach would visit again
|
|
4504
|
+
var callbacks_1 = [];
|
|
4505
|
+
callbackSet.forEach(function (callback) { return callbacks_1.push(callback); });
|
|
4506
|
+
callbacks_1.forEach(function (callback) {
|
|
4507
|
+
if (callbackSet.has(callback)) {
|
|
4508
|
+
callback.apply(callbackSet, args);
|
|
4509
|
+
}
|
|
4510
|
+
});
|
|
4491
4511
|
}
|
|
4492
4512
|
};
|
|
4493
4513
|
return Dispatcher;
|
|
@@ -4938,6 +4958,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
4938
4958
|
* - If the query point is inside a bar, returns the PlotEntity for that bar.
|
|
4939
4959
|
* - Otherwise, gets the nearest PlotEntity by the positional direction (X for vertical, Y for horizontal),
|
|
4940
4960
|
* breaking ties with the secondary direction.
|
|
4961
|
+
* - Remaining ties, such as overlapping bars, go to the bar drawn last (the last Dataset, then the last datum).
|
|
4941
4962
|
* Returns undefined if no PlotEntity can be found.
|
|
4942
4963
|
*
|
|
4943
4964
|
* @param {Point} queryPoint
|
|
@@ -5314,6 +5335,17 @@ var Bar = /** @class */ (function (_super) {
|
|
|
5314
5335
|
var entities = _super.prototype.entities.call(this, datasets);
|
|
5315
5336
|
return entities;
|
|
5316
5337
|
};
|
|
5338
|
+
/**
|
|
5339
|
+
* Undrawn bars stay in `_getDataToDraw` as null placeholders, so the drawer
|
|
5340
|
+
* indexes each bar's element by its dataset index
|
|
5341
|
+
*/
|
|
5342
|
+
Bar.prototype._buildLightweightPlotEntities = function (datasets) {
|
|
5343
|
+
var lightweightPlotEntities = _super.prototype._buildLightweightPlotEntities.call(this, datasets);
|
|
5344
|
+
lightweightPlotEntities.forEach(function (lightweightPlotEntity) {
|
|
5345
|
+
lightweightPlotEntity.validDatumIndex = lightweightPlotEntity.index;
|
|
5346
|
+
});
|
|
5347
|
+
return lightweightPlotEntities;
|
|
5348
|
+
};
|
|
5317
5349
|
Bar.prototype._entityBounds = function (entity) {
|
|
5318
5350
|
var datum = entity.datum, index = entity.index, dataset = entity.dataset;
|
|
5319
5351
|
return this._pixelBounds(datum, index, dataset);
|
|
@@ -7271,7 +7303,14 @@ var Key = /** @class */ (function (_super) {
|
|
|
7271
7303
|
this._keyDispatcher.onKeyUp(this._keyUpCallback);
|
|
7272
7304
|
};
|
|
7273
7305
|
Key.prototype._unanchor = function () {
|
|
7306
|
+
var _this = this;
|
|
7274
7307
|
_super.prototype._unanchor.call(this);
|
|
7308
|
+
// Preserve held keys through synchronous renderTo(), but discard them if keyup can be missed.
|
|
7309
|
+
Promise.resolve().then(function () {
|
|
7310
|
+
if (!_this._isAnchored) {
|
|
7311
|
+
_this._downedKeys = new Utils.Set();
|
|
7312
|
+
}
|
|
7313
|
+
});
|
|
7275
7314
|
this._positionDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
7276
7315
|
this._positionDispatcher = null;
|
|
7277
7316
|
this._keyDispatcher.offKeyDown(this._keyDownCallback);
|
|
@@ -9225,6 +9264,7 @@ var Category = /** @class */ (function (_super) {
|
|
|
9225
9264
|
*/
|
|
9226
9265
|
function Category() {
|
|
9227
9266
|
var _this = _super.call(this) || this;
|
|
9267
|
+
_this._domain = [];
|
|
9228
9268
|
_this._range = [0, 1];
|
|
9229
9269
|
_this._d3Scale = d3.scaleBand();
|
|
9230
9270
|
_this._d3Scale.range(TRANSFORMATION_SPACE);
|
|
@@ -9274,7 +9314,7 @@ var Category = /** @class */ (function (_super) {
|
|
|
9274
9314
|
var normalizedDomain = domain.map(function (d) { return _this._d3Scale(d) + rangeBand / 2; });
|
|
9275
9315
|
var domainStart = d3.bisect(normalizedDomain, domainStartNormalized);
|
|
9276
9316
|
var domainEnd = d3.bisect(normalizedDomain, domainEndNormalized);
|
|
9277
|
-
return
|
|
9317
|
+
return this._domain.slice(domainStart, domainEnd);
|
|
9278
9318
|
};
|
|
9279
9319
|
Category.prototype.range = function (values) {
|
|
9280
9320
|
return _super.prototype.range.call(this, values);
|
|
@@ -9332,8 +9372,9 @@ var Category = /** @class */ (function (_super) {
|
|
|
9332
9372
|
return this;
|
|
9333
9373
|
};
|
|
9334
9374
|
Category.prototype.scale = function (value) {
|
|
9375
|
+
// Accessors read untyped data, so values can be numbers, and 1 and "1" must share a band
|
|
9335
9376
|
// Determine the middle of the range band for the value
|
|
9336
|
-
var untransformed = this._d3Scale(value) + this._d3Scale.bandwidth() / 2;
|
|
9377
|
+
var untransformed = this._d3Scale(String(value)) + this._d3Scale.bandwidth() / 2;
|
|
9337
9378
|
// Convert to screen space
|
|
9338
9379
|
return this._d3TransformationScale(untransformed);
|
|
9339
9380
|
};
|
|
@@ -9374,10 +9415,11 @@ var Category = /** @class */ (function (_super) {
|
|
|
9374
9415
|
};
|
|
9375
9416
|
Category.prototype._backingScaleDomain = function (values) {
|
|
9376
9417
|
if (values == null) {
|
|
9377
|
-
return this.
|
|
9418
|
+
return this._domain.slice();
|
|
9378
9419
|
}
|
|
9379
9420
|
else {
|
|
9380
|
-
this.
|
|
9421
|
+
this._domain = Utils.Array.uniq(values);
|
|
9422
|
+
this._d3Scale.domain(this._domain.map(String));
|
|
9381
9423
|
this._setBands();
|
|
9382
9424
|
return this;
|
|
9383
9425
|
}
|
|
@@ -10040,10 +10082,14 @@ function createMinimizingNodePredicate(point, nearFn, farFn) {
|
|
|
10040
10082
|
}
|
|
10041
10083
|
/**
|
|
10042
10084
|
* Create a `Array.sort` function from a query point and a distance function.
|
|
10085
|
+
*
|
|
10086
|
+
* Nodes are sorted from farthest to nearest. Ties are sorted from first
|
|
10087
|
+
* inserted to last inserted.
|
|
10043
10088
|
*/
|
|
10044
10089
|
function createNodeSort(point, distanceFn) {
|
|
10045
10090
|
return function (a, b) {
|
|
10046
|
-
|
|
10091
|
+
var distanceDifference = distanceFn(b.bounds, point) - distanceFn(a.bounds, point);
|
|
10092
|
+
return distanceDifference !== 0 ? distanceDifference : a.insertionIndex - b.insertionIndex;
|
|
10047
10093
|
};
|
|
10048
10094
|
}
|
|
10049
10095
|
/**
|
|
@@ -10083,6 +10129,7 @@ var RTree = /** @class */ (function () {
|
|
|
10083
10129
|
}
|
|
10084
10130
|
// Insert new value node into leaf node
|
|
10085
10131
|
var valueNode = RTreeNode.valueNode(bounds, value);
|
|
10132
|
+
valueNode.insertionIndex = this.size;
|
|
10086
10133
|
node.insert(valueNode);
|
|
10087
10134
|
this.size += 1;
|
|
10088
10135
|
// While node overflows, split and walk up
|
|
@@ -10103,10 +10150,14 @@ var RTree = /** @class */ (function () {
|
|
|
10103
10150
|
* Nearness is measured as the absolute distance from the query point to the
|
|
10104
10151
|
* nearest edge of the node bounds. If the node bounds contains the query
|
|
10105
10152
|
* point, the distance is 0.
|
|
10153
|
+
*
|
|
10154
|
+
* The results are equally near and sorted by insertion order, ending with
|
|
10155
|
+
* the last inserted value.
|
|
10106
10156
|
*/
|
|
10107
10157
|
RTree.prototype.locateNearest = function (xy) {
|
|
10108
10158
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.distanceSquaredToNearEdge, RTreeBounds.distanceSquaredToFarEdge);
|
|
10109
10159
|
var nodes = this.queryNodes(predicate);
|
|
10160
|
+
nodes.sort(function (a, b) { return a.insertionIndex - b.insertionIndex; });
|
|
10110
10161
|
return nodes.map(function (node) { return node.value; });
|
|
10111
10162
|
};
|
|
10112
10163
|
/**
|
|
@@ -10116,7 +10167,8 @@ var RTree = /** @class */ (function () {
|
|
|
10116
10167
|
* query's x point to the nearest edge of the node bounds. If the node
|
|
10117
10168
|
* bounds contains the query point, the distance is 0.
|
|
10118
10169
|
*
|
|
10119
|
-
* The results are sorted by y-coordinate nearness
|
|
10170
|
+
* The results are sorted by y-coordinate nearness, then by insertion
|
|
10171
|
+
* order, ending with the nearest, last inserted value.
|
|
10120
10172
|
*/
|
|
10121
10173
|
RTree.prototype.locateNearestX = function (xy) {
|
|
10122
10174
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeX, RTreeBounds.absoluteDistanceToFarEdgeX);
|
|
@@ -10131,7 +10183,8 @@ var RTree = /** @class */ (function () {
|
|
|
10131
10183
|
* query's y point to the nearest edge of the node bounds. If the node
|
|
10132
10184
|
* bounds contains the query point, the distance is 0.
|
|
10133
10185
|
*
|
|
10134
|
-
* The results are sorted by x-coordinate nearness
|
|
10186
|
+
* The results are sorted by x-coordinate nearness, then by insertion
|
|
10187
|
+
* order, ending with the nearest, last inserted value.
|
|
10135
10188
|
*/
|
|
10136
10189
|
RTree.prototype.locateNearestY = function (xy) {
|
|
10137
10190
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeY, RTreeBounds.absoluteDistanceToFarEdgeY);
|
|
@@ -10206,6 +10259,7 @@ var RTreeNode = /** @class */ (function () {
|
|
|
10206
10259
|
this.entries = [];
|
|
10207
10260
|
this.parent = null;
|
|
10208
10261
|
this.value = null;
|
|
10262
|
+
this.insertionIndex = null;
|
|
10209
10263
|
}
|
|
10210
10264
|
RTreeNode.valueNode = function (bounds, value) {
|
|
10211
10265
|
var node = new RTreeNode(true);
|
|
@@ -11418,7 +11472,7 @@ exports.version = void 0;
|
|
|
11418
11472
|
* real version number during the dist phase for for npm module publishing. Modifying this line should
|
|
11419
11473
|
* be accompanied by modifying the "sed-version" task in package.json accordingly.
|
|
11420
11474
|
*/
|
|
11421
|
-
exports.version = "4.
|
|
11475
|
+
exports.version = "4.1.0";
|
|
11422
11476
|
|
|
11423
11477
|
|
|
11424
11478
|
/***/ }),
|
|
@@ -13250,12 +13304,20 @@ var Legend = /** @class */ (function (_super) {
|
|
|
13250
13304
|
return _this;
|
|
13251
13305
|
}
|
|
13252
13306
|
Legend.prototype._setup = function () {
|
|
13307
|
+
var _this = this;
|
|
13253
13308
|
_super.prototype._setup.call(this);
|
|
13254
|
-
|
|
13309
|
+
// Keep the row out of content() except while measuring, since renderImmediately() clears content()
|
|
13310
|
+
var fakeLegendRow = d3.create("svg:g").classed(Legend.LEGEND_ROW_CLASS, true);
|
|
13255
13311
|
var fakeLegendEntry = fakeLegendRow.append("g").classed(Legend.LEGEND_ENTRY_CLASS, true);
|
|
13256
13312
|
fakeLegendEntry.append("text");
|
|
13257
13313
|
var context = new Typesettable.SvgContext(fakeLegendRow.node(), null, Configs.ADD_TITLE_ELEMENTS);
|
|
13258
|
-
|
|
13314
|
+
var ruler = context.createRuler();
|
|
13315
|
+
this._measurer = new Typesettable.CacheMeasurer(function (text) {
|
|
13316
|
+
_this.content().append(function () { return fakeLegendRow.node(); });
|
|
13317
|
+
var dimensions = ruler(text);
|
|
13318
|
+
fakeLegendRow.remove();
|
|
13319
|
+
return dimensions;
|
|
13320
|
+
});
|
|
13259
13321
|
this._wrapper = new Typesettable.Wrapper().maxLines(this.maxLinesPerEntry());
|
|
13260
13322
|
this._writer = new Typesettable.Writer(this._measurer, context, this._wrapper);
|
|
13261
13323
|
};
|
|
@@ -14849,7 +14911,14 @@ var Click = /** @class */ (function (_super) {
|
|
|
14849
14911
|
this._touchDispatcher.onTouchCancel(this._touchCancelCallback);
|
|
14850
14912
|
};
|
|
14851
14913
|
Click.prototype._unanchor = function () {
|
|
14914
|
+
var _this = this;
|
|
14852
14915
|
_super.prototype._unanchor.call(this);
|
|
14916
|
+
// Preserve a press through synchronous renderTo(), but discard it if its release can be missed.
|
|
14917
|
+
Promise.resolve().then(function () {
|
|
14918
|
+
if (!_this._isAnchored) {
|
|
14919
|
+
_this._clickedDown = false;
|
|
14920
|
+
}
|
|
14921
|
+
});
|
|
14853
14922
|
this._mouseDispatcher.offMouseDown(this._mouseDownCallback);
|
|
14854
14923
|
this._mouseDispatcher.offMouseUp(this._mouseUpCallback);
|
|
14855
14924
|
this._mouseDispatcher.offDblClick(this._dblClickCallback);
|
|
@@ -14985,7 +15054,13 @@ var Drag = /** @class */ (function (_super) {
|
|
|
14985
15054
|
this._touchDispatcher.onTouchEnd(this._touchEndCallback);
|
|
14986
15055
|
};
|
|
14987
15056
|
Drag.prototype._unanchor = function () {
|
|
15057
|
+
var _this = this;
|
|
14988
15058
|
_super.prototype._unanchor.call(this);
|
|
15059
|
+
Promise.resolve().then(function () {
|
|
15060
|
+
if (!_this._isAnchored) {
|
|
15061
|
+
_this._dragging = false;
|
|
15062
|
+
}
|
|
15063
|
+
});
|
|
14989
15064
|
this._mouseDispatcher.offMouseDown(this._mouseDownCallback);
|
|
14990
15065
|
this._mouseDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
14991
15066
|
this._mouseDispatcher.offMouseUp(this._mouseUpCallback);
|
|
@@ -15258,7 +15333,13 @@ var PanZoom = /** @class */ (function (_super) {
|
|
|
15258
15333
|
this._touchDispatcher.onTouchCancel(this._touchCancelCallback);
|
|
15259
15334
|
};
|
|
15260
15335
|
PanZoom.prototype._unanchor = function () {
|
|
15336
|
+
var _this = this;
|
|
15261
15337
|
_super.prototype._unanchor.call(this);
|
|
15338
|
+
Promise.resolve().then(function () {
|
|
15339
|
+
if (!_this._isAnchored) {
|
|
15340
|
+
_this._touchIds.clear();
|
|
15341
|
+
}
|
|
15342
|
+
});
|
|
15262
15343
|
this._mouseDispatcher.offWheel(this._wheelCallback);
|
|
15263
15344
|
this._mouseDispatcher = null;
|
|
15264
15345
|
this._touchDispatcher.offTouchStart(this._touchStartCallback);
|
|
@@ -15631,7 +15712,14 @@ var Pointer = /** @class */ (function (_super) {
|
|
|
15631
15712
|
this._touchDispatcher.onTouchStart(this._touchStartCallback);
|
|
15632
15713
|
};
|
|
15633
15714
|
Pointer.prototype._unanchor = function () {
|
|
15715
|
+
var _this = this;
|
|
15634
15716
|
_super.prototype._unanchor.call(this);
|
|
15717
|
+
// Preserve hover through synchronous renderTo(), but discard state if pointer events can be missed.
|
|
15718
|
+
Promise.resolve().then(function () {
|
|
15719
|
+
if (!_this._isAnchored) {
|
|
15720
|
+
_this._overComponent = false;
|
|
15721
|
+
}
|
|
15722
|
+
});
|
|
15635
15723
|
this._mouseDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
15636
15724
|
this._mouseDispatcher = null;
|
|
15637
15725
|
this._touchDispatcher.offTouchStart(this._touchStartCallback);
|
|
@@ -16071,6 +16159,7 @@ var Pie = /** @class */ (function (_super) {
|
|
|
16071
16159
|
if (this.outerRadius().scale != null) {
|
|
16072
16160
|
this.outerRadius().scale.range([0, radiusLimit]);
|
|
16073
16161
|
}
|
|
16162
|
+
this._updateExtents();
|
|
16074
16163
|
return this;
|
|
16075
16164
|
};
|
|
16076
16165
|
Pie.prototype.addDataset = function (dataset) {
|
|
@@ -16695,6 +16784,17 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
16695
16784
|
return x <= point.x && point.x <= x + width && y <= point.y && point.y <= y + height;
|
|
16696
16785
|
});
|
|
16697
16786
|
};
|
|
16787
|
+
/**
|
|
16788
|
+
* Undrawn rectangles stay in `_getDataToDraw` as null placeholders, so the
|
|
16789
|
+
* drawer indexes each rectangle's element by its dataset index
|
|
16790
|
+
*/
|
|
16791
|
+
Rectangle.prototype._buildLightweightPlotEntities = function (datasets) {
|
|
16792
|
+
var lightweightPlotEntities = _super.prototype._buildLightweightPlotEntities.call(this, datasets);
|
|
16793
|
+
lightweightPlotEntities.forEach(function (lightweightPlotEntity) {
|
|
16794
|
+
lightweightPlotEntity.validDatumIndex = lightweightPlotEntity.index;
|
|
16795
|
+
});
|
|
16796
|
+
return lightweightPlotEntities;
|
|
16797
|
+
};
|
|
16698
16798
|
Rectangle.prototype._entityBounds = function (entity) {
|
|
16699
16799
|
var datum = entity.datum, index = entity.index, dataset = entity.dataset;
|
|
16700
16800
|
return this._entityBBox(datum, index, dataset, this._getAttrToProjector());
|
|
@@ -17011,6 +17111,33 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
17011
17111
|
return x - size / 2 <= p.x && p.x <= x + size / 2 && y - size / 2 <= p.y && p.y <= y + size / 2;
|
|
17012
17112
|
});
|
|
17013
17113
|
};
|
|
17114
|
+
/**
|
|
17115
|
+
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
17116
|
+
* or undefined if no {Plots.PlotEntity} can be found.
|
|
17117
|
+
*
|
|
17118
|
+
* If the query point is inside several Entities' bounding boxes, returns the
|
|
17119
|
+
* one whose position is nearest, then the one drawn last.
|
|
17120
|
+
*
|
|
17121
|
+
* @param {Point} queryPoint
|
|
17122
|
+
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
17123
|
+
*/
|
|
17124
|
+
Scatter.prototype.entityNearest = function (queryPoint) {
|
|
17125
|
+
var containing = this._getEntityStore().entitiesInBounds({ x: queryPoint.x, y: queryPoint.y, width: 0, height: 0 });
|
|
17126
|
+
if (containing.length === 0) {
|
|
17127
|
+
return _super.prototype.entityNearest.call(this, queryPoint);
|
|
17128
|
+
}
|
|
17129
|
+
containing.sort(function (a, b) { return a.datasetIndex - b.datasetIndex || a.index - b.index; });
|
|
17130
|
+
var nearest;
|
|
17131
|
+
var minDistSquared = Infinity;
|
|
17132
|
+
containing.forEach(function (entity) {
|
|
17133
|
+
var distSquared = Utils.Math.distanceSquared(entity.position, queryPoint);
|
|
17134
|
+
if (distSquared <= minDistSquared) {
|
|
17135
|
+
nearest = entity;
|
|
17136
|
+
minDistSquared = distSquared;
|
|
17137
|
+
}
|
|
17138
|
+
});
|
|
17139
|
+
return this._lightweightPlotEntityToPlotEntity(nearest);
|
|
17140
|
+
};
|
|
17014
17141
|
Scatter.prototype.labelsEnabled = function (enabled) {
|
|
17015
17142
|
if (enabled == null) {
|
|
17016
17143
|
return this._labelsEnabled;
|
|
@@ -18040,41 +18167,6 @@ var tslib_1 = __webpack_require__(0);
|
|
|
18040
18167
|
var d3 = __webpack_require__(2);
|
|
18041
18168
|
var Utils = __webpack_require__(1);
|
|
18042
18169
|
var scale_1 = __webpack_require__(18);
|
|
18043
|
-
/**
|
|
18044
|
-
* Workaround for bad d3 behavior.
|
|
18045
|
-
*
|
|
18046
|
-
* d3's color scales, which are oridinal scales, have side-effects when invoked.
|
|
18047
|
-
* When you call the `scale(value)` as a function, it will implicitly add new
|
|
18048
|
-
* values to the domain.
|
|
18049
|
-
*
|
|
18050
|
-
* These side-effects cause us to rely on looking up the current scale state
|
|
18051
|
-
* with the `.domain()` and `.range()` methods. However, these methods have poor
|
|
18052
|
-
* performance implications since they will always slice their internal values
|
|
18053
|
-
* before returning. Inside the inner render loop of color scatter plot points,
|
|
18054
|
-
* these slices add up.
|
|
18055
|
-
*/
|
|
18056
|
-
var ImplicitSeriesTracker = /** @class */ (function () {
|
|
18057
|
-
function ImplicitSeriesTracker() {
|
|
18058
|
-
this.count = 0;
|
|
18059
|
-
this.tracker = {};
|
|
18060
|
-
}
|
|
18061
|
-
ImplicitSeriesTracker.prototype.getIndex = function (value) {
|
|
18062
|
-
if (this.tracker[value] != null) {
|
|
18063
|
-
return this.tracker[value];
|
|
18064
|
-
}
|
|
18065
|
-
else {
|
|
18066
|
-
var idx = this.count;
|
|
18067
|
-
this.tracker[value] = idx;
|
|
18068
|
-
this.count += 1;
|
|
18069
|
-
return idx;
|
|
18070
|
-
}
|
|
18071
|
-
};
|
|
18072
|
-
ImplicitSeriesTracker.prototype.clear = function () {
|
|
18073
|
-
this.count = 0;
|
|
18074
|
-
this.tracker = {};
|
|
18075
|
-
};
|
|
18076
|
-
return ImplicitSeriesTracker;
|
|
18077
|
-
}());
|
|
18078
18170
|
// Preserve the public D3 4 palette names removed in D3 5.
|
|
18079
18171
|
var CATEGORY20 = [
|
|
18080
18172
|
"#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
|
|
@@ -18106,43 +18198,41 @@ var Color = /** @class */ (function (_super) {
|
|
|
18106
18198
|
*/
|
|
18107
18199
|
function Color(scaleType) {
|
|
18108
18200
|
var _this = _super.call(this) || this;
|
|
18109
|
-
|
|
18110
|
-
_this.
|
|
18111
|
-
|
|
18112
|
-
var scale;
|
|
18201
|
+
_this._domain = [];
|
|
18202
|
+
_this._domainIndices = new Map();
|
|
18203
|
+
var range;
|
|
18113
18204
|
switch (scaleType) {
|
|
18114
18205
|
case null:
|
|
18115
18206
|
case undefined:
|
|
18116
18207
|
if (Color._plottableColorCache == null) {
|
|
18117
18208
|
Color._plottableColorCache = Color._getPlottableColors();
|
|
18118
18209
|
}
|
|
18119
|
-
|
|
18210
|
+
range = Color._plottableColorCache;
|
|
18120
18211
|
break;
|
|
18121
18212
|
case "Category10":
|
|
18122
18213
|
case "category10":
|
|
18123
18214
|
case "10":
|
|
18124
|
-
|
|
18215
|
+
range = d3.schemeCategory10;
|
|
18125
18216
|
break;
|
|
18126
18217
|
case "Category20":
|
|
18127
18218
|
case "category20":
|
|
18128
18219
|
case "20":
|
|
18129
|
-
|
|
18220
|
+
range = CATEGORY20;
|
|
18130
18221
|
break;
|
|
18131
18222
|
case "Category20b":
|
|
18132
18223
|
case "category20b":
|
|
18133
18224
|
case "20b":
|
|
18134
|
-
|
|
18225
|
+
range = CATEGORY20B;
|
|
18135
18226
|
break;
|
|
18136
18227
|
case "Category20c":
|
|
18137
18228
|
case "category20c":
|
|
18138
18229
|
case "20c":
|
|
18139
|
-
|
|
18230
|
+
range = CATEGORY20C;
|
|
18140
18231
|
break;
|
|
18141
18232
|
default:
|
|
18142
18233
|
throw new Error("Unsupported ColorScale type");
|
|
18143
18234
|
}
|
|
18144
|
-
_this.
|
|
18145
|
-
_this._rangeLength = _this._d3Scale.range().length;
|
|
18235
|
+
_this._range = range.slice();
|
|
18146
18236
|
return _this;
|
|
18147
18237
|
}
|
|
18148
18238
|
Color.prototype.extentOfValues = function (values) {
|
|
@@ -18182,34 +18272,45 @@ var Color = /** @class */ (function (_super) {
|
|
|
18182
18272
|
* @returns {string}
|
|
18183
18273
|
*/
|
|
18184
18274
|
Color.prototype.scale = function (value) {
|
|
18185
|
-
var
|
|
18186
|
-
var
|
|
18187
|
-
var numLooped = Math.floor(index / this.
|
|
18275
|
+
var index = this._domainIndex(value);
|
|
18276
|
+
var color = this._range[index % this._range.length];
|
|
18277
|
+
var numLooped = Math.floor(index / this._range.length);
|
|
18188
18278
|
if (numLooped === 0) {
|
|
18189
18279
|
return color;
|
|
18190
18280
|
}
|
|
18191
18281
|
var modifyFactor = Math.log(numLooped * Color._LOOP_LIGHTEN_FACTOR + 1);
|
|
18192
18282
|
return Utils.Color.lightenColor(color, modifyFactor);
|
|
18193
18283
|
};
|
|
18284
|
+
Color.prototype._domainIndex = function (value) {
|
|
18285
|
+
// Accessors read untyped data, so values can be numbers, and 1 and "1" must share a color
|
|
18286
|
+
var key = String(value);
|
|
18287
|
+
var index = this._domainIndices.get(key);
|
|
18288
|
+
if (index == null) {
|
|
18289
|
+
index = this._domain.push(value) - 1;
|
|
18290
|
+
this._domainIndices.set(key, index);
|
|
18291
|
+
}
|
|
18292
|
+
return index;
|
|
18293
|
+
};
|
|
18194
18294
|
Color.prototype._getDomain = function () {
|
|
18195
18295
|
return this._backingScaleDomain();
|
|
18196
18296
|
};
|
|
18197
18297
|
Color.prototype._backingScaleDomain = function (values) {
|
|
18298
|
+
var _this = this;
|
|
18198
18299
|
if (values == null) {
|
|
18199
|
-
return this.
|
|
18300
|
+
return this._domain.slice();
|
|
18200
18301
|
}
|
|
18201
18302
|
else {
|
|
18202
|
-
this.
|
|
18203
|
-
this.
|
|
18303
|
+
this._domain = [];
|
|
18304
|
+
this._domainIndices.clear();
|
|
18305
|
+
values.forEach(function (value) { return _this._domainIndex(value); });
|
|
18204
18306
|
return this;
|
|
18205
18307
|
}
|
|
18206
18308
|
};
|
|
18207
18309
|
Color.prototype._getRange = function () {
|
|
18208
|
-
return this.
|
|
18310
|
+
return this._range.slice();
|
|
18209
18311
|
};
|
|
18210
18312
|
Color.prototype._setRange = function (values) {
|
|
18211
|
-
this.
|
|
18212
|
-
this._rangeLength = values.length;
|
|
18313
|
+
this._range = values.slice();
|
|
18213
18314
|
};
|
|
18214
18315
|
Color._LOOP_LIGHTEN_FACTOR = 1.6;
|
|
18215
18316
|
// The maximum number of colors we are getting from CSS stylesheets
|
|
@@ -18235,6 +18336,7 @@ var tslib_1 = __webpack_require__(0);
|
|
|
18235
18336
|
var d3 = __webpack_require__(2);
|
|
18236
18337
|
var Utils = __webpack_require__(1);
|
|
18237
18338
|
var scale_1 = __webpack_require__(18);
|
|
18339
|
+
var UNKNOWN_COLOR = "rgb(0, 0, 0)";
|
|
18238
18340
|
var InterpolatedColor = /** @class */ (function (_super) {
|
|
18239
18341
|
tslib_1.__extends(InterpolatedColor, _super);
|
|
18240
18342
|
/**
|
|
@@ -18247,16 +18349,16 @@ var InterpolatedColor = /** @class */ (function (_super) {
|
|
|
18247
18349
|
var _this = _super.call(this) || this;
|
|
18248
18350
|
switch (scaleType) {
|
|
18249
18351
|
case "linear":
|
|
18250
|
-
_this._colorScale = d3.scaleLinear();
|
|
18352
|
+
_this._colorScale = d3.scaleLinear().unknown(UNKNOWN_COLOR);
|
|
18251
18353
|
break;
|
|
18252
18354
|
case "log":
|
|
18253
|
-
_this._colorScale = d3.scaleLog();
|
|
18355
|
+
_this._colorScale = d3.scaleLog().unknown(UNKNOWN_COLOR);
|
|
18254
18356
|
break;
|
|
18255
18357
|
case "sqrt":
|
|
18256
|
-
_this._colorScale = d3.scaleSqrt();
|
|
18358
|
+
_this._colorScale = d3.scaleSqrt().unknown(UNKNOWN_COLOR);
|
|
18257
18359
|
break;
|
|
18258
18360
|
case "pow":
|
|
18259
|
-
_this._colorScale = d3.scalePow();
|
|
18361
|
+
_this._colorScale = d3.scalePow().unknown(UNKNOWN_COLOR);
|
|
18260
18362
|
break;
|
|
18261
18363
|
}
|
|
18262
18364
|
if (_this._colorScale == null) {
|
|
@@ -19669,6 +19771,39 @@ function stackedExtent(stackingResult, keyAccessor, filter) {
|
|
|
19669
19771
|
var minStackExtent = Utils.Math.min(extents, 0);
|
|
19670
19772
|
return [nativeMath.min(minStackExtent, 0), nativeMath.max(0, maxStackExtent)];
|
|
19671
19773
|
}
|
|
19774
|
+
/**
|
|
19775
|
+
* A lodash `MapCache` backed by a `WeakMap`, so each cached string is
|
|
19776
|
+
* released once its key object (such as a `Date`) is garbage collected.
|
|
19777
|
+
* Primitive keys are never cached: a `WeakMap` cannot hold them, and
|
|
19778
|
+
* `String()` on a primitive costs no more than a cache lookup.
|
|
19779
|
+
*/
|
|
19780
|
+
var WeakKeyCache = /** @class */ (function () {
|
|
19781
|
+
function WeakKeyCache() {
|
|
19782
|
+
this.map = new WeakMap();
|
|
19783
|
+
}
|
|
19784
|
+
WeakKeyCache.prototype.get = function (key) {
|
|
19785
|
+
return this.isObjectKey(key) ? this.map.get(key) : undefined;
|
|
19786
|
+
};
|
|
19787
|
+
WeakKeyCache.prototype.has = function (key) {
|
|
19788
|
+
return this.isObjectKey(key) && this.map.has(key);
|
|
19789
|
+
};
|
|
19790
|
+
WeakKeyCache.prototype.set = function (key, value) {
|
|
19791
|
+
if (this.isObjectKey(key)) {
|
|
19792
|
+
this.map.set(key, value);
|
|
19793
|
+
}
|
|
19794
|
+
return this;
|
|
19795
|
+
};
|
|
19796
|
+
WeakKeyCache.prototype.delete = function (key) {
|
|
19797
|
+
return this.isObjectKey(key) && this.map.delete(key);
|
|
19798
|
+
};
|
|
19799
|
+
WeakKeyCache.prototype.clear = function () {
|
|
19800
|
+
this.map = new WeakMap();
|
|
19801
|
+
};
|
|
19802
|
+
WeakKeyCache.prototype.isObjectKey = function (key) {
|
|
19803
|
+
return typeof key === "object" && key !== null;
|
|
19804
|
+
};
|
|
19805
|
+
return WeakKeyCache;
|
|
19806
|
+
}());
|
|
19672
19807
|
/**
|
|
19673
19808
|
* Normalizes a key used for stacking
|
|
19674
19809
|
*
|
|
@@ -19678,6 +19813,7 @@ function stackedExtent(stackingResult, keyAccessor, filter) {
|
|
|
19678
19813
|
exports.normalizeKey = (0, memoize_1.default)(function (key) {
|
|
19679
19814
|
return String(key);
|
|
19680
19815
|
});
|
|
19816
|
+
exports.normalizeKey.cache = new WeakKeyCache();
|
|
19681
19817
|
|
|
19682
19818
|
|
|
19683
19819
|
/***/ }),
|