plottable 4.0.0 → 4.1.1
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/drawers/svgDrawer.d.ts +4 -0
- package/build/src/drawers/svgDrawer.js +15 -6
- 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/memoize/memoizeProjectors.js +41 -9
- 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 +265 -88
- package/plottable.js.map +1 -1
package/plottable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Plottable 4.
|
|
2
|
+
* Plottable 4.1.1 (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
|
*/
|
|
@@ -2286,10 +2288,12 @@ var SVGDrawer = /** @class */ (function () {
|
|
|
2286
2288
|
// first store source data index before any filtering takes place
|
|
2287
2289
|
var mappedData = data.map(function (d, i) { return d != null ? { d: d, i: i } : null; });
|
|
2288
2290
|
// Whereas canvas renders can cope with null data values, svg renderer
|
|
2289
|
-
// attribute accessors assume non-null data values, so we must filter them
|
|
2290
|
-
// out. Unfortunately, this means the index passed to each accessor will
|
|
2291
|
-
// not necessarily match the index of the datum in the dataset.
|
|
2291
|
+
// attribute accessors assume non-null data values, so we must filter them out
|
|
2292
2292
|
var filteredData = mappedData.filter(function (d) { return d != null; });
|
|
2293
|
+
this._sourceDataIndices = filteredData.map(function (_a) {
|
|
2294
|
+
var i = _a.i;
|
|
2295
|
+
return i;
|
|
2296
|
+
});
|
|
2293
2297
|
var dataElementsUpdate = this._root.selectAll(this.selector()).data(filteredData);
|
|
2294
2298
|
this._selection = dataElementsUpdate
|
|
2295
2299
|
.enter()
|
|
@@ -2323,13 +2327,20 @@ var SVGDrawer = /** @class */ (function () {
|
|
|
2323
2327
|
*/
|
|
2324
2328
|
SVGDrawer.prototype._drawStep = function (step) {
|
|
2325
2329
|
var _this = this;
|
|
2330
|
+
// d3 passes each element's position in _selection, which skips null data, so map it back to the source data index
|
|
2331
|
+
var sourceDataIndices = this._sourceDataIndices;
|
|
2332
|
+
var attrToSourceIndexProjector = {};
|
|
2333
|
+
Object.keys(step.attrToAppliedProjector).forEach(function (attr) {
|
|
2334
|
+
var projector = step.attrToAppliedProjector[attr];
|
|
2335
|
+
attrToSourceIndexProjector[attr] = function (datum, position) { return projector(datum, sourceDataIndices[position]); };
|
|
2336
|
+
});
|
|
2326
2337
|
var colorAttributes = ["fill", "stroke"];
|
|
2327
2338
|
colorAttributes.forEach(function (colorAttribute) {
|
|
2328
|
-
if (
|
|
2329
|
-
_this._selection.attr(colorAttribute,
|
|
2339
|
+
if (attrToSourceIndexProjector[colorAttribute] != null) {
|
|
2340
|
+
_this._selection.attr(colorAttribute, attrToSourceIndexProjector[colorAttribute]);
|
|
2330
2341
|
}
|
|
2331
2342
|
});
|
|
2332
|
-
step.animator.animate(this._selection,
|
|
2343
|
+
step.animator.animate(this._selection, attrToSourceIndexProjector);
|
|
2333
2344
|
if (this._className != null) {
|
|
2334
2345
|
this._selection.classed(this._className, true);
|
|
2335
2346
|
}
|
|
@@ -2733,7 +2744,15 @@ exports.Interaction = void 0;
|
|
|
2733
2744
|
var Interaction = /** @class */ (function () {
|
|
2734
2745
|
function Interaction() {
|
|
2735
2746
|
var _this = this;
|
|
2736
|
-
this._anchorCallback = function (component) {
|
|
2747
|
+
this._anchorCallback = function (component) {
|
|
2748
|
+
_this._detachCallback();
|
|
2749
|
+
_this._anchor(component);
|
|
2750
|
+
};
|
|
2751
|
+
this._detachCallback = function () {
|
|
2752
|
+
if (_this._isAnchored) {
|
|
2753
|
+
_this._unanchor();
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2737
2756
|
this._enabled = true;
|
|
2738
2757
|
}
|
|
2739
2758
|
/**
|
|
@@ -2812,6 +2831,7 @@ var Interaction = /** @class */ (function () {
|
|
|
2812
2831
|
Interaction.prototype._connect = function () {
|
|
2813
2832
|
if (this.enabled() && this._componentAttachedTo != null && !this._isAnchored) {
|
|
2814
2833
|
this._componentAttachedTo.onAnchor(this._anchorCallback);
|
|
2834
|
+
this._componentAttachedTo.onDetach(this._detachCallback);
|
|
2815
2835
|
}
|
|
2816
2836
|
};
|
|
2817
2837
|
Interaction.prototype._disconnect = function () {
|
|
@@ -2820,6 +2840,7 @@ var Interaction = /** @class */ (function () {
|
|
|
2820
2840
|
}
|
|
2821
2841
|
if (this._componentAttachedTo != null) {
|
|
2822
2842
|
this._componentAttachedTo.offAnchor(this._anchorCallback);
|
|
2843
|
+
this._componentAttachedTo.offDetach(this._detachCallback);
|
|
2823
2844
|
}
|
|
2824
2845
|
};
|
|
2825
2846
|
return Interaction;
|
|
@@ -3030,6 +3051,7 @@ var XYPlot = /** @class */ (function (_super) {
|
|
|
3030
3051
|
yScale.range([this.height(), 0]);
|
|
3031
3052
|
}
|
|
3032
3053
|
}
|
|
3054
|
+
this._updateExtents();
|
|
3033
3055
|
return this;
|
|
3034
3056
|
};
|
|
3035
3057
|
XYPlot.prototype._updateXExtentsAndAutodomain = function () {
|
|
@@ -4487,7 +4509,14 @@ var Dispatcher = /** @class */ (function () {
|
|
|
4487
4509
|
}
|
|
4488
4510
|
var callbackSet = this._eventNameToCallbackSet[eventName];
|
|
4489
4511
|
if (callbackSet != null) {
|
|
4490
|
-
|
|
4512
|
+
// Interactions can resubscribe while handling an event, which Set.forEach would visit again
|
|
4513
|
+
var callbacks_1 = [];
|
|
4514
|
+
callbackSet.forEach(function (callback) { return callbacks_1.push(callback); });
|
|
4515
|
+
callbacks_1.forEach(function (callback) {
|
|
4516
|
+
if (callbackSet.has(callback)) {
|
|
4517
|
+
callback.apply(callbackSet, args);
|
|
4518
|
+
}
|
|
4519
|
+
});
|
|
4491
4520
|
}
|
|
4492
4521
|
};
|
|
4493
4522
|
return Dispatcher;
|
|
@@ -4938,6 +4967,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
4938
4967
|
* - If the query point is inside a bar, returns the PlotEntity for that bar.
|
|
4939
4968
|
* - Otherwise, gets the nearest PlotEntity by the positional direction (X for vertical, Y for horizontal),
|
|
4940
4969
|
* breaking ties with the secondary direction.
|
|
4970
|
+
* - Remaining ties, such as overlapping bars, go to the bar drawn last (the last Dataset, then the last datum).
|
|
4941
4971
|
* Returns undefined if no PlotEntity can be found.
|
|
4942
4972
|
*
|
|
4943
4973
|
* @param {Point} queryPoint
|
|
@@ -5314,6 +5344,17 @@ var Bar = /** @class */ (function (_super) {
|
|
|
5314
5344
|
var entities = _super.prototype.entities.call(this, datasets);
|
|
5315
5345
|
return entities;
|
|
5316
5346
|
};
|
|
5347
|
+
/**
|
|
5348
|
+
* Undrawn bars stay in `_getDataToDraw` as null placeholders, so the drawer
|
|
5349
|
+
* indexes each bar's element by its dataset index
|
|
5350
|
+
*/
|
|
5351
|
+
Bar.prototype._buildLightweightPlotEntities = function (datasets) {
|
|
5352
|
+
var lightweightPlotEntities = _super.prototype._buildLightweightPlotEntities.call(this, datasets);
|
|
5353
|
+
lightweightPlotEntities.forEach(function (lightweightPlotEntity) {
|
|
5354
|
+
lightweightPlotEntity.validDatumIndex = lightweightPlotEntity.index;
|
|
5355
|
+
});
|
|
5356
|
+
return lightweightPlotEntities;
|
|
5357
|
+
};
|
|
5317
5358
|
Bar.prototype._entityBounds = function (entity) {
|
|
5318
5359
|
var datum = entity.datum, index = entity.index, dataset = entity.dataset;
|
|
5319
5360
|
return this._pixelBounds(datum, index, dataset);
|
|
@@ -7271,7 +7312,14 @@ var Key = /** @class */ (function (_super) {
|
|
|
7271
7312
|
this._keyDispatcher.onKeyUp(this._keyUpCallback);
|
|
7272
7313
|
};
|
|
7273
7314
|
Key.prototype._unanchor = function () {
|
|
7315
|
+
var _this = this;
|
|
7274
7316
|
_super.prototype._unanchor.call(this);
|
|
7317
|
+
// Preserve held keys through synchronous renderTo(), but discard them if keyup can be missed.
|
|
7318
|
+
Promise.resolve().then(function () {
|
|
7319
|
+
if (!_this._isAnchored) {
|
|
7320
|
+
_this._downedKeys = new Utils.Set();
|
|
7321
|
+
}
|
|
7322
|
+
});
|
|
7275
7323
|
this._positionDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
7276
7324
|
this._positionDispatcher = null;
|
|
7277
7325
|
this._keyDispatcher.offKeyDown(this._keyDownCallback);
|
|
@@ -9225,6 +9273,7 @@ var Category = /** @class */ (function (_super) {
|
|
|
9225
9273
|
*/
|
|
9226
9274
|
function Category() {
|
|
9227
9275
|
var _this = _super.call(this) || this;
|
|
9276
|
+
_this._domain = [];
|
|
9228
9277
|
_this._range = [0, 1];
|
|
9229
9278
|
_this._d3Scale = d3.scaleBand();
|
|
9230
9279
|
_this._d3Scale.range(TRANSFORMATION_SPACE);
|
|
@@ -9274,7 +9323,7 @@ var Category = /** @class */ (function (_super) {
|
|
|
9274
9323
|
var normalizedDomain = domain.map(function (d) { return _this._d3Scale(d) + rangeBand / 2; });
|
|
9275
9324
|
var domainStart = d3.bisect(normalizedDomain, domainStartNormalized);
|
|
9276
9325
|
var domainEnd = d3.bisect(normalizedDomain, domainEndNormalized);
|
|
9277
|
-
return
|
|
9326
|
+
return this._domain.slice(domainStart, domainEnd);
|
|
9278
9327
|
};
|
|
9279
9328
|
Category.prototype.range = function (values) {
|
|
9280
9329
|
return _super.prototype.range.call(this, values);
|
|
@@ -9332,8 +9381,9 @@ var Category = /** @class */ (function (_super) {
|
|
|
9332
9381
|
return this;
|
|
9333
9382
|
};
|
|
9334
9383
|
Category.prototype.scale = function (value) {
|
|
9384
|
+
// Accessors read untyped data, so values can be numbers, and 1 and "1" must share a band
|
|
9335
9385
|
// Determine the middle of the range band for the value
|
|
9336
|
-
var untransformed = this._d3Scale(value) + this._d3Scale.bandwidth() / 2;
|
|
9386
|
+
var untransformed = this._d3Scale(String(value)) + this._d3Scale.bandwidth() / 2;
|
|
9337
9387
|
// Convert to screen space
|
|
9338
9388
|
return this._d3TransformationScale(untransformed);
|
|
9339
9389
|
};
|
|
@@ -9374,10 +9424,11 @@ var Category = /** @class */ (function (_super) {
|
|
|
9374
9424
|
};
|
|
9375
9425
|
Category.prototype._backingScaleDomain = function (values) {
|
|
9376
9426
|
if (values == null) {
|
|
9377
|
-
return this.
|
|
9427
|
+
return this._domain.slice();
|
|
9378
9428
|
}
|
|
9379
9429
|
else {
|
|
9380
|
-
this.
|
|
9430
|
+
this._domain = Utils.Array.uniq(values);
|
|
9431
|
+
this._d3Scale.domain(this._domain.map(String));
|
|
9381
9432
|
this._setBands();
|
|
9382
9433
|
return this;
|
|
9383
9434
|
}
|
|
@@ -10040,10 +10091,14 @@ function createMinimizingNodePredicate(point, nearFn, farFn) {
|
|
|
10040
10091
|
}
|
|
10041
10092
|
/**
|
|
10042
10093
|
* Create a `Array.sort` function from a query point and a distance function.
|
|
10094
|
+
*
|
|
10095
|
+
* Nodes are sorted from farthest to nearest. Ties are sorted from first
|
|
10096
|
+
* inserted to last inserted.
|
|
10043
10097
|
*/
|
|
10044
10098
|
function createNodeSort(point, distanceFn) {
|
|
10045
10099
|
return function (a, b) {
|
|
10046
|
-
|
|
10100
|
+
var distanceDifference = distanceFn(b.bounds, point) - distanceFn(a.bounds, point);
|
|
10101
|
+
return distanceDifference !== 0 ? distanceDifference : a.insertionIndex - b.insertionIndex;
|
|
10047
10102
|
};
|
|
10048
10103
|
}
|
|
10049
10104
|
/**
|
|
@@ -10083,6 +10138,7 @@ var RTree = /** @class */ (function () {
|
|
|
10083
10138
|
}
|
|
10084
10139
|
// Insert new value node into leaf node
|
|
10085
10140
|
var valueNode = RTreeNode.valueNode(bounds, value);
|
|
10141
|
+
valueNode.insertionIndex = this.size;
|
|
10086
10142
|
node.insert(valueNode);
|
|
10087
10143
|
this.size += 1;
|
|
10088
10144
|
// While node overflows, split and walk up
|
|
@@ -10103,10 +10159,14 @@ var RTree = /** @class */ (function () {
|
|
|
10103
10159
|
* Nearness is measured as the absolute distance from the query point to the
|
|
10104
10160
|
* nearest edge of the node bounds. If the node bounds contains the query
|
|
10105
10161
|
* point, the distance is 0.
|
|
10162
|
+
*
|
|
10163
|
+
* The results are equally near and sorted by insertion order, ending with
|
|
10164
|
+
* the last inserted value.
|
|
10106
10165
|
*/
|
|
10107
10166
|
RTree.prototype.locateNearest = function (xy) {
|
|
10108
10167
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.distanceSquaredToNearEdge, RTreeBounds.distanceSquaredToFarEdge);
|
|
10109
10168
|
var nodes = this.queryNodes(predicate);
|
|
10169
|
+
nodes.sort(function (a, b) { return a.insertionIndex - b.insertionIndex; });
|
|
10110
10170
|
return nodes.map(function (node) { return node.value; });
|
|
10111
10171
|
};
|
|
10112
10172
|
/**
|
|
@@ -10116,7 +10176,8 @@ var RTree = /** @class */ (function () {
|
|
|
10116
10176
|
* query's x point to the nearest edge of the node bounds. If the node
|
|
10117
10177
|
* bounds contains the query point, the distance is 0.
|
|
10118
10178
|
*
|
|
10119
|
-
* The results are sorted by y-coordinate nearness
|
|
10179
|
+
* The results are sorted by y-coordinate nearness, then by insertion
|
|
10180
|
+
* order, ending with the nearest, last inserted value.
|
|
10120
10181
|
*/
|
|
10121
10182
|
RTree.prototype.locateNearestX = function (xy) {
|
|
10122
10183
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeX, RTreeBounds.absoluteDistanceToFarEdgeX);
|
|
@@ -10131,7 +10192,8 @@ var RTree = /** @class */ (function () {
|
|
|
10131
10192
|
* query's y point to the nearest edge of the node bounds. If the node
|
|
10132
10193
|
* bounds contains the query point, the distance is 0.
|
|
10133
10194
|
*
|
|
10134
|
-
* The results are sorted by x-coordinate nearness
|
|
10195
|
+
* The results are sorted by x-coordinate nearness, then by insertion
|
|
10196
|
+
* order, ending with the nearest, last inserted value.
|
|
10135
10197
|
*/
|
|
10136
10198
|
RTree.prototype.locateNearestY = function (xy) {
|
|
10137
10199
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeY, RTreeBounds.absoluteDistanceToFarEdgeY);
|
|
@@ -10206,6 +10268,7 @@ var RTreeNode = /** @class */ (function () {
|
|
|
10206
10268
|
this.entries = [];
|
|
10207
10269
|
this.parent = null;
|
|
10208
10270
|
this.value = null;
|
|
10271
|
+
this.insertionIndex = null;
|
|
10209
10272
|
}
|
|
10210
10273
|
RTreeNode.valueNode = function (bounds, value) {
|
|
10211
10274
|
var node = new RTreeNode(true);
|
|
@@ -11418,7 +11481,7 @@ exports.version = void 0;
|
|
|
11418
11481
|
* real version number during the dist phase for for npm module publishing. Modifying this line should
|
|
11419
11482
|
* be accompanied by modifying the "sed-version" task in package.json accordingly.
|
|
11420
11483
|
*/
|
|
11421
|
-
exports.version = "4.
|
|
11484
|
+
exports.version = "4.1.1";
|
|
11422
11485
|
|
|
11423
11486
|
|
|
11424
11487
|
/***/ }),
|
|
@@ -13250,12 +13313,20 @@ var Legend = /** @class */ (function (_super) {
|
|
|
13250
13313
|
return _this;
|
|
13251
13314
|
}
|
|
13252
13315
|
Legend.prototype._setup = function () {
|
|
13316
|
+
var _this = this;
|
|
13253
13317
|
_super.prototype._setup.call(this);
|
|
13254
|
-
|
|
13318
|
+
// Keep the row out of content() except while measuring, since renderImmediately() clears content()
|
|
13319
|
+
var fakeLegendRow = d3.create("svg:g").classed(Legend.LEGEND_ROW_CLASS, true);
|
|
13255
13320
|
var fakeLegendEntry = fakeLegendRow.append("g").classed(Legend.LEGEND_ENTRY_CLASS, true);
|
|
13256
13321
|
fakeLegendEntry.append("text");
|
|
13257
13322
|
var context = new Typesettable.SvgContext(fakeLegendRow.node(), null, Configs.ADD_TITLE_ELEMENTS);
|
|
13258
|
-
|
|
13323
|
+
var ruler = context.createRuler();
|
|
13324
|
+
this._measurer = new Typesettable.CacheMeasurer(function (text) {
|
|
13325
|
+
_this.content().append(function () { return fakeLegendRow.node(); });
|
|
13326
|
+
var dimensions = ruler(text);
|
|
13327
|
+
fakeLegendRow.remove();
|
|
13328
|
+
return dimensions;
|
|
13329
|
+
});
|
|
13259
13330
|
this._wrapper = new Typesettable.Wrapper().maxLines(this.maxLinesPerEntry());
|
|
13260
13331
|
this._writer = new Typesettable.Writer(this._measurer, context, this._wrapper);
|
|
13261
13332
|
};
|
|
@@ -14849,7 +14920,14 @@ var Click = /** @class */ (function (_super) {
|
|
|
14849
14920
|
this._touchDispatcher.onTouchCancel(this._touchCancelCallback);
|
|
14850
14921
|
};
|
|
14851
14922
|
Click.prototype._unanchor = function () {
|
|
14923
|
+
var _this = this;
|
|
14852
14924
|
_super.prototype._unanchor.call(this);
|
|
14925
|
+
// Preserve a press through synchronous renderTo(), but discard it if its release can be missed.
|
|
14926
|
+
Promise.resolve().then(function () {
|
|
14927
|
+
if (!_this._isAnchored) {
|
|
14928
|
+
_this._clickedDown = false;
|
|
14929
|
+
}
|
|
14930
|
+
});
|
|
14853
14931
|
this._mouseDispatcher.offMouseDown(this._mouseDownCallback);
|
|
14854
14932
|
this._mouseDispatcher.offMouseUp(this._mouseUpCallback);
|
|
14855
14933
|
this._mouseDispatcher.offDblClick(this._dblClickCallback);
|
|
@@ -14985,7 +15063,13 @@ var Drag = /** @class */ (function (_super) {
|
|
|
14985
15063
|
this._touchDispatcher.onTouchEnd(this._touchEndCallback);
|
|
14986
15064
|
};
|
|
14987
15065
|
Drag.prototype._unanchor = function () {
|
|
15066
|
+
var _this = this;
|
|
14988
15067
|
_super.prototype._unanchor.call(this);
|
|
15068
|
+
Promise.resolve().then(function () {
|
|
15069
|
+
if (!_this._isAnchored) {
|
|
15070
|
+
_this._dragging = false;
|
|
15071
|
+
}
|
|
15072
|
+
});
|
|
14989
15073
|
this._mouseDispatcher.offMouseDown(this._mouseDownCallback);
|
|
14990
15074
|
this._mouseDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
14991
15075
|
this._mouseDispatcher.offMouseUp(this._mouseUpCallback);
|
|
@@ -15258,7 +15342,13 @@ var PanZoom = /** @class */ (function (_super) {
|
|
|
15258
15342
|
this._touchDispatcher.onTouchCancel(this._touchCancelCallback);
|
|
15259
15343
|
};
|
|
15260
15344
|
PanZoom.prototype._unanchor = function () {
|
|
15345
|
+
var _this = this;
|
|
15261
15346
|
_super.prototype._unanchor.call(this);
|
|
15347
|
+
Promise.resolve().then(function () {
|
|
15348
|
+
if (!_this._isAnchored) {
|
|
15349
|
+
_this._touchIds.clear();
|
|
15350
|
+
}
|
|
15351
|
+
});
|
|
15262
15352
|
this._mouseDispatcher.offWheel(this._wheelCallback);
|
|
15263
15353
|
this._mouseDispatcher = null;
|
|
15264
15354
|
this._touchDispatcher.offTouchStart(this._touchStartCallback);
|
|
@@ -15631,7 +15721,14 @@ var Pointer = /** @class */ (function (_super) {
|
|
|
15631
15721
|
this._touchDispatcher.onTouchStart(this._touchStartCallback);
|
|
15632
15722
|
};
|
|
15633
15723
|
Pointer.prototype._unanchor = function () {
|
|
15724
|
+
var _this = this;
|
|
15634
15725
|
_super.prototype._unanchor.call(this);
|
|
15726
|
+
// Preserve hover through synchronous renderTo(), but discard state if pointer events can be missed.
|
|
15727
|
+
Promise.resolve().then(function () {
|
|
15728
|
+
if (!_this._isAnchored) {
|
|
15729
|
+
_this._overComponent = false;
|
|
15730
|
+
}
|
|
15731
|
+
});
|
|
15635
15732
|
this._mouseDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
15636
15733
|
this._mouseDispatcher = null;
|
|
15637
15734
|
this._touchDispatcher.offTouchStart(this._touchStartCallback);
|
|
@@ -15893,8 +15990,40 @@ var IndexMap = /** @class */ (function () {
|
|
|
15893
15990
|
return IndexMap;
|
|
15894
15991
|
}());
|
|
15895
15992
|
/**
|
|
15896
|
-
*
|
|
15897
|
-
*
|
|
15993
|
+
* An `IndexMap` that records the datum each value was computed for in place of
|
|
15994
|
+
* an existence flag, so a lookup only matches that datum
|
|
15995
|
+
*/
|
|
15996
|
+
var DatumIndexMap = /** @class */ (function () {
|
|
15997
|
+
function DatumIndexMap() {
|
|
15998
|
+
this.values = Object.create(null);
|
|
15999
|
+
this.datums = Object.create(null);
|
|
16000
|
+
}
|
|
16001
|
+
DatumIndexMap.prototype.delete = function (key) {
|
|
16002
|
+
delete this.values[key];
|
|
16003
|
+
delete this.datums[key];
|
|
16004
|
+
return true;
|
|
16005
|
+
};
|
|
16006
|
+
DatumIndexMap.prototype.get = function (key) {
|
|
16007
|
+
return this.values[key];
|
|
16008
|
+
};
|
|
16009
|
+
DatumIndexMap.prototype.has = function (key, datum) {
|
|
16010
|
+
return this.datums[key] === datum && (datum !== undefined || key in this.datums);
|
|
16011
|
+
};
|
|
16012
|
+
DatumIndexMap.prototype.set = function (key, datum, value) {
|
|
16013
|
+
this.values[key] = value;
|
|
16014
|
+
this.datums[key] = datum;
|
|
16015
|
+
return this;
|
|
16016
|
+
};
|
|
16017
|
+
return DatumIndexMap;
|
|
16018
|
+
}());
|
|
16019
|
+
/**
|
|
16020
|
+
* A lodash-style `MapCache` keyed by [updateId, index, datum], stored as a
|
|
16021
|
+
* fast-lookup 2D index on the first two. This is much faster than stringifying
|
|
16022
|
+
* the key.
|
|
16023
|
+
*
|
|
16024
|
+
* Entries only match the datum they were computed for, because plots that
|
|
16025
|
+
* filter data before drawing call projectors with each datum's position in the
|
|
16026
|
+
* filtered data rather than its dataset index.
|
|
15898
16027
|
*/
|
|
15899
16028
|
var DatasetIndexCache = /** @class */ (function () {
|
|
15900
16029
|
function DatasetIndexCache() {
|
|
@@ -15904,24 +16033,24 @@ var DatasetIndexCache = /** @class */ (function () {
|
|
|
15904
16033
|
return this.map.get(key[0]).get(key[1]);
|
|
15905
16034
|
};
|
|
15906
16035
|
DatasetIndexCache.prototype.has = function (key) {
|
|
15907
|
-
return this.map.has(key[0]) && this.map.get(key[0]).has(key[1]);
|
|
16036
|
+
return this.map.has(key[0]) && this.map.get(key[0]).has(key[1], key[2]);
|
|
15908
16037
|
};
|
|
15909
16038
|
DatasetIndexCache.prototype.set = function (key, value) {
|
|
15910
|
-
this.map.has(key[0]) || this.map.set(key[0], new
|
|
15911
|
-
this.map.get(key[0]).set(key[1], value);
|
|
16039
|
+
this.map.has(key[0]) || this.map.set(key[0], new DatumIndexMap());
|
|
16040
|
+
this.map.get(key[0]).set(key[1], key[2], value);
|
|
15912
16041
|
return this;
|
|
15913
16042
|
};
|
|
15914
16043
|
DatasetIndexCache.prototype.delete = function (key) {
|
|
15915
|
-
// NOTE: this can potentially leave dangling `
|
|
15916
|
-
// all the keys from the index instead of using `clear`. The
|
|
15917
|
-
// minimal, so this is fine.
|
|
16044
|
+
// NOTE: this can potentially leave dangling `DatumIndexMap`s if we
|
|
16045
|
+
// delete all the keys from the index instead of using `clear`. The
|
|
16046
|
+
// overhead is minimal, so this is fine.
|
|
15918
16047
|
this.map.has(key[0]) && this.map.get(key[0]).delete(key[1]);
|
|
15919
16048
|
return true;
|
|
15920
16049
|
};
|
|
15921
16050
|
DatasetIndexCache.prototype.clear = function () {
|
|
15922
16051
|
this.map = new IndexMap();
|
|
15923
16052
|
};
|
|
15924
|
-
DatasetIndexCache.resolver = function (d, i, dataset) { return [dataset.updateId(), i]; };
|
|
16053
|
+
DatasetIndexCache.resolver = function (d, i, dataset) { return [dataset.updateId(), i, d]; };
|
|
15925
16054
|
return DatasetIndexCache;
|
|
15926
16055
|
}());
|
|
15927
16056
|
function memoizeProjector(projector) {
|
|
@@ -16071,6 +16200,7 @@ var Pie = /** @class */ (function (_super) {
|
|
|
16071
16200
|
if (this.outerRadius().scale != null) {
|
|
16072
16201
|
this.outerRadius().scale.range([0, radiusLimit]);
|
|
16073
16202
|
}
|
|
16203
|
+
this._updateExtents();
|
|
16074
16204
|
return this;
|
|
16075
16205
|
};
|
|
16076
16206
|
Pie.prototype.addDataset = function (dataset) {
|
|
@@ -16695,6 +16825,17 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
16695
16825
|
return x <= point.x && point.x <= x + width && y <= point.y && point.y <= y + height;
|
|
16696
16826
|
});
|
|
16697
16827
|
};
|
|
16828
|
+
/**
|
|
16829
|
+
* Undrawn rectangles stay in `_getDataToDraw` as null placeholders, so the
|
|
16830
|
+
* drawer indexes each rectangle's element by its dataset index
|
|
16831
|
+
*/
|
|
16832
|
+
Rectangle.prototype._buildLightweightPlotEntities = function (datasets) {
|
|
16833
|
+
var lightweightPlotEntities = _super.prototype._buildLightweightPlotEntities.call(this, datasets);
|
|
16834
|
+
lightweightPlotEntities.forEach(function (lightweightPlotEntity) {
|
|
16835
|
+
lightweightPlotEntity.validDatumIndex = lightweightPlotEntity.index;
|
|
16836
|
+
});
|
|
16837
|
+
return lightweightPlotEntities;
|
|
16838
|
+
};
|
|
16698
16839
|
Rectangle.prototype._entityBounds = function (entity) {
|
|
16699
16840
|
var datum = entity.datum, index = entity.index, dataset = entity.dataset;
|
|
16700
16841
|
return this._entityBBox(datum, index, dataset, this._getAttrToProjector());
|
|
@@ -17011,6 +17152,33 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
17011
17152
|
return x - size / 2 <= p.x && p.x <= x + size / 2 && y - size / 2 <= p.y && p.y <= y + size / 2;
|
|
17012
17153
|
});
|
|
17013
17154
|
};
|
|
17155
|
+
/**
|
|
17156
|
+
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
17157
|
+
* or undefined if no {Plots.PlotEntity} can be found.
|
|
17158
|
+
*
|
|
17159
|
+
* If the query point is inside several Entities' bounding boxes, returns the
|
|
17160
|
+
* one whose position is nearest, then the one drawn last.
|
|
17161
|
+
*
|
|
17162
|
+
* @param {Point} queryPoint
|
|
17163
|
+
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
17164
|
+
*/
|
|
17165
|
+
Scatter.prototype.entityNearest = function (queryPoint) {
|
|
17166
|
+
var containing = this._getEntityStore().entitiesInBounds({ x: queryPoint.x, y: queryPoint.y, width: 0, height: 0 });
|
|
17167
|
+
if (containing.length === 0) {
|
|
17168
|
+
return _super.prototype.entityNearest.call(this, queryPoint);
|
|
17169
|
+
}
|
|
17170
|
+
containing.sort(function (a, b) { return a.datasetIndex - b.datasetIndex || a.index - b.index; });
|
|
17171
|
+
var nearest;
|
|
17172
|
+
var minDistSquared = Infinity;
|
|
17173
|
+
containing.forEach(function (entity) {
|
|
17174
|
+
var distSquared = Utils.Math.distanceSquared(entity.position, queryPoint);
|
|
17175
|
+
if (distSquared <= minDistSquared) {
|
|
17176
|
+
nearest = entity;
|
|
17177
|
+
minDistSquared = distSquared;
|
|
17178
|
+
}
|
|
17179
|
+
});
|
|
17180
|
+
return this._lightweightPlotEntityToPlotEntity(nearest);
|
|
17181
|
+
};
|
|
17014
17182
|
Scatter.prototype.labelsEnabled = function (enabled) {
|
|
17015
17183
|
if (enabled == null) {
|
|
17016
17184
|
return this._labelsEnabled;
|
|
@@ -18040,41 +18208,6 @@ var tslib_1 = __webpack_require__(0);
|
|
|
18040
18208
|
var d3 = __webpack_require__(2);
|
|
18041
18209
|
var Utils = __webpack_require__(1);
|
|
18042
18210
|
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
18211
|
// Preserve the public D3 4 palette names removed in D3 5.
|
|
18079
18212
|
var CATEGORY20 = [
|
|
18080
18213
|
"#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
|
|
@@ -18106,43 +18239,41 @@ var Color = /** @class */ (function (_super) {
|
|
|
18106
18239
|
*/
|
|
18107
18240
|
function Color(scaleType) {
|
|
18108
18241
|
var _this = _super.call(this) || this;
|
|
18109
|
-
|
|
18110
|
-
_this.
|
|
18111
|
-
|
|
18112
|
-
var scale;
|
|
18242
|
+
_this._domain = [];
|
|
18243
|
+
_this._domainIndices = new Map();
|
|
18244
|
+
var range;
|
|
18113
18245
|
switch (scaleType) {
|
|
18114
18246
|
case null:
|
|
18115
18247
|
case undefined:
|
|
18116
18248
|
if (Color._plottableColorCache == null) {
|
|
18117
18249
|
Color._plottableColorCache = Color._getPlottableColors();
|
|
18118
18250
|
}
|
|
18119
|
-
|
|
18251
|
+
range = Color._plottableColorCache;
|
|
18120
18252
|
break;
|
|
18121
18253
|
case "Category10":
|
|
18122
18254
|
case "category10":
|
|
18123
18255
|
case "10":
|
|
18124
|
-
|
|
18256
|
+
range = d3.schemeCategory10;
|
|
18125
18257
|
break;
|
|
18126
18258
|
case "Category20":
|
|
18127
18259
|
case "category20":
|
|
18128
18260
|
case "20":
|
|
18129
|
-
|
|
18261
|
+
range = CATEGORY20;
|
|
18130
18262
|
break;
|
|
18131
18263
|
case "Category20b":
|
|
18132
18264
|
case "category20b":
|
|
18133
18265
|
case "20b":
|
|
18134
|
-
|
|
18266
|
+
range = CATEGORY20B;
|
|
18135
18267
|
break;
|
|
18136
18268
|
case "Category20c":
|
|
18137
18269
|
case "category20c":
|
|
18138
18270
|
case "20c":
|
|
18139
|
-
|
|
18271
|
+
range = CATEGORY20C;
|
|
18140
18272
|
break;
|
|
18141
18273
|
default:
|
|
18142
18274
|
throw new Error("Unsupported ColorScale type");
|
|
18143
18275
|
}
|
|
18144
|
-
_this.
|
|
18145
|
-
_this._rangeLength = _this._d3Scale.range().length;
|
|
18276
|
+
_this._range = range.slice();
|
|
18146
18277
|
return _this;
|
|
18147
18278
|
}
|
|
18148
18279
|
Color.prototype.extentOfValues = function (values) {
|
|
@@ -18182,34 +18313,45 @@ var Color = /** @class */ (function (_super) {
|
|
|
18182
18313
|
* @returns {string}
|
|
18183
18314
|
*/
|
|
18184
18315
|
Color.prototype.scale = function (value) {
|
|
18185
|
-
var
|
|
18186
|
-
var
|
|
18187
|
-
var numLooped = Math.floor(index / this.
|
|
18316
|
+
var index = this._domainIndex(value);
|
|
18317
|
+
var color = this._range[index % this._range.length];
|
|
18318
|
+
var numLooped = Math.floor(index / this._range.length);
|
|
18188
18319
|
if (numLooped === 0) {
|
|
18189
18320
|
return color;
|
|
18190
18321
|
}
|
|
18191
18322
|
var modifyFactor = Math.log(numLooped * Color._LOOP_LIGHTEN_FACTOR + 1);
|
|
18192
18323
|
return Utils.Color.lightenColor(color, modifyFactor);
|
|
18193
18324
|
};
|
|
18325
|
+
Color.prototype._domainIndex = function (value) {
|
|
18326
|
+
// Accessors read untyped data, so values can be numbers, and 1 and "1" must share a color
|
|
18327
|
+
var key = String(value);
|
|
18328
|
+
var index = this._domainIndices.get(key);
|
|
18329
|
+
if (index == null) {
|
|
18330
|
+
index = this._domain.push(value) - 1;
|
|
18331
|
+
this._domainIndices.set(key, index);
|
|
18332
|
+
}
|
|
18333
|
+
return index;
|
|
18334
|
+
};
|
|
18194
18335
|
Color.prototype._getDomain = function () {
|
|
18195
18336
|
return this._backingScaleDomain();
|
|
18196
18337
|
};
|
|
18197
18338
|
Color.prototype._backingScaleDomain = function (values) {
|
|
18339
|
+
var _this = this;
|
|
18198
18340
|
if (values == null) {
|
|
18199
|
-
return this.
|
|
18341
|
+
return this._domain.slice();
|
|
18200
18342
|
}
|
|
18201
18343
|
else {
|
|
18202
|
-
this.
|
|
18203
|
-
this.
|
|
18344
|
+
this._domain = [];
|
|
18345
|
+
this._domainIndices.clear();
|
|
18346
|
+
values.forEach(function (value) { return _this._domainIndex(value); });
|
|
18204
18347
|
return this;
|
|
18205
18348
|
}
|
|
18206
18349
|
};
|
|
18207
18350
|
Color.prototype._getRange = function () {
|
|
18208
|
-
return this.
|
|
18351
|
+
return this._range.slice();
|
|
18209
18352
|
};
|
|
18210
18353
|
Color.prototype._setRange = function (values) {
|
|
18211
|
-
this.
|
|
18212
|
-
this._rangeLength = values.length;
|
|
18354
|
+
this._range = values.slice();
|
|
18213
18355
|
};
|
|
18214
18356
|
Color._LOOP_LIGHTEN_FACTOR = 1.6;
|
|
18215
18357
|
// The maximum number of colors we are getting from CSS stylesheets
|
|
@@ -18235,6 +18377,7 @@ var tslib_1 = __webpack_require__(0);
|
|
|
18235
18377
|
var d3 = __webpack_require__(2);
|
|
18236
18378
|
var Utils = __webpack_require__(1);
|
|
18237
18379
|
var scale_1 = __webpack_require__(18);
|
|
18380
|
+
var UNKNOWN_COLOR = "rgb(0, 0, 0)";
|
|
18238
18381
|
var InterpolatedColor = /** @class */ (function (_super) {
|
|
18239
18382
|
tslib_1.__extends(InterpolatedColor, _super);
|
|
18240
18383
|
/**
|
|
@@ -18247,16 +18390,16 @@ var InterpolatedColor = /** @class */ (function (_super) {
|
|
|
18247
18390
|
var _this = _super.call(this) || this;
|
|
18248
18391
|
switch (scaleType) {
|
|
18249
18392
|
case "linear":
|
|
18250
|
-
_this._colorScale = d3.scaleLinear();
|
|
18393
|
+
_this._colorScale = d3.scaleLinear().unknown(UNKNOWN_COLOR);
|
|
18251
18394
|
break;
|
|
18252
18395
|
case "log":
|
|
18253
|
-
_this._colorScale = d3.scaleLog();
|
|
18396
|
+
_this._colorScale = d3.scaleLog().unknown(UNKNOWN_COLOR);
|
|
18254
18397
|
break;
|
|
18255
18398
|
case "sqrt":
|
|
18256
|
-
_this._colorScale = d3.scaleSqrt();
|
|
18399
|
+
_this._colorScale = d3.scaleSqrt().unknown(UNKNOWN_COLOR);
|
|
18257
18400
|
break;
|
|
18258
18401
|
case "pow":
|
|
18259
|
-
_this._colorScale = d3.scalePow();
|
|
18402
|
+
_this._colorScale = d3.scalePow().unknown(UNKNOWN_COLOR);
|
|
18260
18403
|
break;
|
|
18261
18404
|
}
|
|
18262
18405
|
if (_this._colorScale == null) {
|
|
@@ -19669,6 +19812,39 @@ function stackedExtent(stackingResult, keyAccessor, filter) {
|
|
|
19669
19812
|
var minStackExtent = Utils.Math.min(extents, 0);
|
|
19670
19813
|
return [nativeMath.min(minStackExtent, 0), nativeMath.max(0, maxStackExtent)];
|
|
19671
19814
|
}
|
|
19815
|
+
/**
|
|
19816
|
+
* A lodash `MapCache` backed by a `WeakMap`, so each cached string is
|
|
19817
|
+
* released once its key object (such as a `Date`) is garbage collected.
|
|
19818
|
+
* Primitive keys are never cached: a `WeakMap` cannot hold them, and
|
|
19819
|
+
* `String()` on a primitive costs no more than a cache lookup.
|
|
19820
|
+
*/
|
|
19821
|
+
var WeakKeyCache = /** @class */ (function () {
|
|
19822
|
+
function WeakKeyCache() {
|
|
19823
|
+
this.map = new WeakMap();
|
|
19824
|
+
}
|
|
19825
|
+
WeakKeyCache.prototype.get = function (key) {
|
|
19826
|
+
return this.isObjectKey(key) ? this.map.get(key) : undefined;
|
|
19827
|
+
};
|
|
19828
|
+
WeakKeyCache.prototype.has = function (key) {
|
|
19829
|
+
return this.isObjectKey(key) && this.map.has(key);
|
|
19830
|
+
};
|
|
19831
|
+
WeakKeyCache.prototype.set = function (key, value) {
|
|
19832
|
+
if (this.isObjectKey(key)) {
|
|
19833
|
+
this.map.set(key, value);
|
|
19834
|
+
}
|
|
19835
|
+
return this;
|
|
19836
|
+
};
|
|
19837
|
+
WeakKeyCache.prototype.delete = function (key) {
|
|
19838
|
+
return this.isObjectKey(key) && this.map.delete(key);
|
|
19839
|
+
};
|
|
19840
|
+
WeakKeyCache.prototype.clear = function () {
|
|
19841
|
+
this.map = new WeakMap();
|
|
19842
|
+
};
|
|
19843
|
+
WeakKeyCache.prototype.isObjectKey = function (key) {
|
|
19844
|
+
return typeof key === "object" && key !== null;
|
|
19845
|
+
};
|
|
19846
|
+
return WeakKeyCache;
|
|
19847
|
+
}());
|
|
19672
19848
|
/**
|
|
19673
19849
|
* Normalizes a key used for stacking
|
|
19674
19850
|
*
|
|
@@ -19678,6 +19854,7 @@ function stackedExtent(stackingResult, keyAccessor, filter) {
|
|
|
19678
19854
|
exports.normalizeKey = (0, memoize_1.default)(function (key) {
|
|
19679
19855
|
return String(key);
|
|
19680
19856
|
});
|
|
19857
|
+
exports.normalizeKey.cache = new WeakKeyCache();
|
|
19681
19858
|
|
|
19682
19859
|
|
|
19683
19860
|
/***/ }),
|