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.
- package/README.md +9 -2
- package/build/src/animators/easingAnimator.d.ts +2 -2
- package/build/src/animators/easingAnimator.js +1 -1
- package/build/src/animators/index.js +2 -2
- package/build/src/axes/axis.d.ts +1 -1
- package/build/src/axes/axis.js +5 -5
- package/build/src/axes/categoryAxis.js +8 -7
- package/build/src/axes/index.js +3 -3
- package/build/src/axes/numericAxis.js +1 -1
- package/build/src/axes/timeAxis.d.ts +5 -5
- package/build/src/axes/timeAxis.js +6 -6
- package/build/src/components/component.d.ts +4 -4
- package/build/src/components/component.js +4 -4
- package/build/src/components/componentContainer.js +1 -1
- package/build/src/components/dragBoxLayer.d.ts +1 -1
- package/build/src/components/dragBoxLayer.js +1 -1
- package/build/src/components/dragLineLayer.js +1 -1
- package/build/src/components/gridlines.js +1 -1
- package/build/src/components/group.js +1 -1
- package/build/src/components/guideLineLayer.js +1 -1
- package/build/src/components/index.js +14 -14
- package/build/src/components/interpolatedColorLegend.js +1 -1
- package/build/src/components/label.d.ts +1 -1
- package/build/src/components/label.js +3 -3
- package/build/src/components/legend.js +17 -9
- package/build/src/components/plotGroup.js +1 -1
- package/build/src/components/selectionBoxLayer.js +2 -2
- package/build/src/components/table.js +1 -1
- package/build/src/components/wrappedLabel.js +1 -1
- package/build/src/components/xDragBoxLayer.js +1 -1
- package/build/src/components/yDragBoxLayer.js +1 -1
- package/build/src/core/dataset.d.ts +1 -1
- package/build/src/core/formatters.d.ts +2 -2
- package/build/src/core/formatters.js +16 -13
- package/build/src/core/interfaces.d.ts +9 -9
- package/build/src/core/renderController.d.ts +1 -1
- package/build/src/core/renderController.js +6 -6
- package/build/src/core/symbolFactories.d.ts +2 -2
- package/build/src/core/symbolFactories.js +15 -15
- package/build/src/core/version.js +1 -1
- package/build/src/dispatchers/dispatcher.js +8 -1
- package/build/src/dispatchers/index.js +3 -3
- package/build/src/dispatchers/keyDispatcher.d.ts +1 -1
- package/build/src/dispatchers/keyDispatcher.js +1 -1
- package/build/src/dispatchers/mouseDispatcher.d.ts +1 -1
- package/build/src/dispatchers/mouseDispatcher.js +1 -1
- package/build/src/dispatchers/touchDispatcher.d.ts +1 -1
- package/build/src/dispatchers/touchDispatcher.js +1 -1
- package/build/src/drawers/arcDrawer.js +1 -1
- package/build/src/drawers/arcOutlineDrawer.js +1 -1
- package/build/src/drawers/areaDrawer.js +3 -3
- package/build/src/drawers/canvasBuffer.js +2 -2
- package/build/src/drawers/canvasDrawer.d.ts +1 -1
- package/build/src/drawers/canvasDrawer.js +8 -8
- package/build/src/drawers/drawStep.d.ts +2 -2
- package/build/src/drawers/index.js +11 -11
- package/build/src/drawers/lineDrawer.js +3 -3
- package/build/src/drawers/rectangleDrawer.js +2 -2
- package/build/src/drawers/segmentDrawer.js +1 -1
- package/build/src/drawers/symbolDrawer.js +3 -3
- package/build/src/index.js +14 -14
- package/build/src/interactions/clickInteraction.d.ts +1 -1
- package/build/src/interactions/clickInteraction.js +8 -1
- package/build/src/interactions/dragInteraction.d.ts +2 -2
- package/build/src/interactions/dragInteraction.js +7 -1
- package/build/src/interactions/index.js +5 -5
- package/build/src/interactions/interaction.d.ts +2 -1
- package/build/src/interactions/interaction.js +11 -1
- package/build/src/interactions/keyInteraction.d.ts +1 -1
- package/build/src/interactions/keyInteraction.js +8 -1
- package/build/src/interactions/panZoomConstraints.js +5 -6
- package/build/src/interactions/panZoomInteraction.d.ts +4 -4
- package/build/src/interactions/panZoomInteraction.js +15 -10
- package/build/src/interactions/pointerInteraction.d.ts +1 -1
- package/build/src/interactions/pointerInteraction.js +8 -1
- package/build/src/memoize/index.js +3 -3
- package/build/src/memoize/memThunk.d.ts +1 -1
- package/build/src/memoize/memThunk.js +1 -2
- package/build/src/memoize/memoize.d.ts +1 -1
- package/build/src/memoize/memoize.js +1 -2
- package/build/src/memoize/memoizeProjectors.js +2 -3
- package/build/src/memoize/signature.d.ts +1 -1
- package/build/src/memoize/signature.js +10 -10
- package/build/src/plots/areaPlot.js +4 -3
- package/build/src/plots/barPlot.d.ts +9 -3
- package/build/src/plots/barPlot.js +18 -6
- package/build/src/plots/clusteredBarPlot.js +1 -1
- package/build/src/plots/commons.js +1 -1
- package/build/src/plots/index.js +12 -12
- package/build/src/plots/linePlot.d.ts +2 -3
- package/build/src/plots/linePlot.js +3 -2
- package/build/src/plots/piePlot.js +4 -2
- package/build/src/plots/plot.d.ts +4 -2
- package/build/src/plots/plot.js +12 -10
- package/build/src/plots/rectanglePlot.d.ts +5 -0
- package/build/src/plots/rectanglePlot.js +14 -4
- package/build/src/plots/scatterPlot.d.ts +11 -0
- package/build/src/plots/scatterPlot.js +31 -4
- package/build/src/plots/segmentPlot.js +1 -1
- package/build/src/plots/stackedAreaPlot.js +5 -6
- package/build/src/plots/stackedBarPlot.js +4 -4
- package/build/src/plots/waterfallPlot.js +1 -1
- package/build/src/plots/xyPlot.js +4 -3
- package/build/src/scales/categoryScale.d.ts +1 -0
- package/build/src/scales/categoryScale.js +9 -6
- package/build/src/scales/colorScale.d.ts +4 -3
- package/build/src/scales/colorScale.js +50 -57
- package/build/src/scales/index.js +9 -9
- package/build/src/scales/interpolatedColorScale.js +11 -10
- package/build/src/scales/linearScale.js +3 -3
- package/build/src/scales/logScale.js +3 -3
- package/build/src/scales/modifiedLogScale.js +2 -2
- package/build/src/scales/quantitativeScale.js +1 -1
- package/build/src/scales/scale.d.ts +1 -1
- package/build/src/scales/tickGenerators.js +2 -3
- package/build/src/scales/timeScale.js +4 -4
- package/build/src/utils/arrayUtils.js +5 -7
- package/build/src/utils/callbackSet.js +1 -1
- package/build/src/utils/coerceD3.js +1 -2
- package/build/src/utils/colorUtils.js +3 -4
- package/build/src/utils/d3ShapeUtils.d.ts +11 -0
- package/build/src/utils/d3ShapeUtils.js +17 -0
- package/build/src/utils/domUtils.js +20 -20
- package/build/src/utils/entityStore.d.ts +6 -3
- package/build/src/utils/index.js +8 -8
- package/build/src/utils/makeEnum.js +1 -2
- package/build/src/utils/mathUtils.d.ts +2 -2
- package/build/src/utils/mathUtils.js +17 -18
- package/build/src/utils/objectUtils.js +1 -2
- package/build/src/utils/rTree.d.ts +12 -3
- package/build/src/utils/rTree.js +19 -7
- package/build/src/utils/rTreeSplitStrategies.d.ts +1 -1
- package/build/src/utils/stackingUtils.d.ts +6 -6
- package/build/src/utils/stackingUtils.js +40 -7
- package/build/src/utils/transformAwareTranslator.js +2 -2
- package/build/src/utils/windowUtils.js +4 -5
- package/package.json +15 -14
- package/plottable.css +4 -3
- package/plottable.js +18083 -18287
- package/plottable.js.map +1 -1
|
@@ -17,20 +17,20 @@ export declare const BarOrientation: {
|
|
|
17
17
|
vertical: "vertical";
|
|
18
18
|
horizontal: "horizontal";
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type BarOrientation = keyof typeof BarOrientation;
|
|
21
21
|
export declare const LabelsPosition: {
|
|
22
22
|
end: "end";
|
|
23
23
|
start: "start";
|
|
24
24
|
middle: "middle";
|
|
25
25
|
outside: "outside";
|
|
26
26
|
};
|
|
27
|
-
export
|
|
27
|
+
export type LabelsPosition = keyof typeof LabelsPosition;
|
|
28
28
|
export declare const BarAlignment: {
|
|
29
29
|
end: "end";
|
|
30
30
|
start: "start";
|
|
31
31
|
middle: "middle";
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type BarAlignment = keyof typeof BarAlignment;
|
|
34
34
|
export declare class Bar<X, Y> extends XYPlot<X, Y> {
|
|
35
35
|
static _BAR_THICKNESS_RATIO: number;
|
|
36
36
|
static _BAR_GAPLESS_THRESHOLD_PX: number;
|
|
@@ -199,6 +199,7 @@ export declare class Bar<X, Y> extends XYPlot<X, Y> {
|
|
|
199
199
|
* - If the query point is inside a bar, returns the PlotEntity for that bar.
|
|
200
200
|
* - Otherwise, gets the nearest PlotEntity by the positional direction (X for vertical, Y for horizontal),
|
|
201
201
|
* breaking ties with the secondary direction.
|
|
202
|
+
* - Remaining ties, such as overlapping bars, go to the bar drawn last (the last Dataset, then the last datum).
|
|
202
203
|
* Returns undefined if no PlotEntity can be found.
|
|
203
204
|
*
|
|
204
205
|
* @param {Point} queryPoint
|
|
@@ -243,6 +244,11 @@ export declare class Bar<X, Y> extends XYPlot<X, Y> {
|
|
|
243
244
|
protected _updateThicknessAttr(): void;
|
|
244
245
|
private _barPixelThickness;
|
|
245
246
|
entities(datasets?: Dataset[]): IPlotEntity[];
|
|
247
|
+
/**
|
|
248
|
+
* Undrawn bars stay in `_getDataToDraw` as null placeholders, so the drawer
|
|
249
|
+
* indexes each bar's element by its dataset index
|
|
250
|
+
*/
|
|
251
|
+
protected _buildLightweightPlotEntities(datasets: Dataset[]): Plots.ILightweightPlotEntity[];
|
|
246
252
|
protected _entityBounds(entity: Plots.IPlotEntity | Plots.ILightweightPlotEntity): Pick<DOMRect, "height" | "width" | "x" | "y">;
|
|
247
253
|
/**
|
|
248
254
|
* The rectangular bounds of a bar. Note that the x/y coordinates are not the
|
|
@@ -26,7 +26,7 @@ exports.BarOrientation = (0, makeEnum_1.makeEnum)(["vertical", "horizontal"]);
|
|
|
26
26
|
exports.LabelsPosition = (0, makeEnum_1.makeEnum)(["start", "middle", "end", "outside"]);
|
|
27
27
|
exports.BarAlignment = (0, makeEnum_1.makeEnum)(["start", "middle", "end"]);
|
|
28
28
|
var Bar = /** @class */ (function (_super) {
|
|
29
|
-
|
|
29
|
+
tslib_1.__extends(Bar, _super);
|
|
30
30
|
/**
|
|
31
31
|
* A Bar Plot draws bars growing out from a baseline to some value
|
|
32
32
|
*
|
|
@@ -226,7 +226,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
226
226
|
// clearing to remove outdated font-size classes
|
|
227
227
|
labelArea.attr("class", null)
|
|
228
228
|
.classed(Bar._LABEL_AREA_CLASS, true)
|
|
229
|
-
.classed("label-"
|
|
229
|
+
.classed("label-".concat(_this._labelFontSize), true);
|
|
230
230
|
});
|
|
231
231
|
return this.render();
|
|
232
232
|
}
|
|
@@ -235,7 +235,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
235
235
|
var drawer = _super.prototype._createNodesForDataset.call(this, dataset);
|
|
236
236
|
var labelArea = this._renderArea.append("g")
|
|
237
237
|
.classed(Bar._LABEL_AREA_CLASS, true)
|
|
238
|
-
.classed("label-"
|
|
238
|
+
.classed("label-".concat(this._labelFontSize), true);
|
|
239
239
|
var context = new Typesettable.SvgContext(labelArea.node());
|
|
240
240
|
var measurer = new Typesettable.CacheMeasurer(context);
|
|
241
241
|
var writer = new Typesettable.Writer(measurer, context);
|
|
@@ -255,6 +255,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
255
255
|
* - If the query point is inside a bar, returns the PlotEntity for that bar.
|
|
256
256
|
* - Otherwise, gets the nearest PlotEntity by the positional direction (X for vertical, Y for horizontal),
|
|
257
257
|
* breaking ties with the secondary direction.
|
|
258
|
+
* - Remaining ties, such as overlapping bars, go to the bar drawn last (the last Dataset, then the last datum).
|
|
258
259
|
* Returns undefined if no PlotEntity can be found.
|
|
259
260
|
*
|
|
260
261
|
* @param {Point} queryPoint
|
|
@@ -525,7 +526,7 @@ var Bar = /** @class */ (function (_super) {
|
|
|
525
526
|
};
|
|
526
527
|
};
|
|
527
528
|
Bar.prototype._createLabelContainer = function (labelArea, labelContainerOrigin, labelOrigin, measurement, showLabelOnBar, color) {
|
|
528
|
-
var labelContainer = labelArea.append("g").attr("transform", "translate("
|
|
529
|
+
var labelContainer = labelArea.append("g").attr("transform", "translate(".concat(labelContainerOrigin.x, ", ").concat(labelContainerOrigin.y, ")"));
|
|
529
530
|
if (showLabelOnBar) {
|
|
530
531
|
labelContainer.classed("on-bar-label", true);
|
|
531
532
|
var dark = Utils.Color.contrast("white", color) * 1.6 < Utils.Color.contrast("black", color);
|
|
@@ -631,6 +632,17 @@ var Bar = /** @class */ (function (_super) {
|
|
|
631
632
|
var entities = _super.prototype.entities.call(this, datasets);
|
|
632
633
|
return entities;
|
|
633
634
|
};
|
|
635
|
+
/**
|
|
636
|
+
* Undrawn bars stay in `_getDataToDraw` as null placeholders, so the drawer
|
|
637
|
+
* indexes each bar's element by its dataset index
|
|
638
|
+
*/
|
|
639
|
+
Bar.prototype._buildLightweightPlotEntities = function (datasets) {
|
|
640
|
+
var lightweightPlotEntities = _super.prototype._buildLightweightPlotEntities.call(this, datasets);
|
|
641
|
+
lightweightPlotEntities.forEach(function (lightweightPlotEntity) {
|
|
642
|
+
lightweightPlotEntity.validDatumIndex = lightweightPlotEntity.index;
|
|
643
|
+
});
|
|
644
|
+
return lightweightPlotEntities;
|
|
645
|
+
};
|
|
634
646
|
Bar.prototype._entityBounds = function (entity) {
|
|
635
647
|
var datum = entity.datum, index = entity.index, dataset = entity.dataset;
|
|
636
648
|
return this._pixelBounds(datum, index, dataset);
|
|
@@ -751,11 +763,11 @@ function computeBarPixelThickness(positionBinding, datasets, plotPositionDimensi
|
|
|
751
763
|
}
|
|
752
764
|
else {
|
|
753
765
|
var positionAccessor_1 = positionBinding.accessor;
|
|
754
|
-
var numberBarAccessorData =
|
|
766
|
+
var numberBarAccessorData = Utils.Array.uniq(Utils.Array.flatten(datasets.map(function (dataset) {
|
|
755
767
|
return dataset.data().map(function (d, i) { return positionAccessor_1(d, i, dataset); })
|
|
756
768
|
.filter(function (d) { return d != null; })
|
|
757
769
|
.map(function (d) { return d.valueOf(); });
|
|
758
|
-
}))).
|
|
770
|
+
}))).map(function (value) { return +value; });
|
|
759
771
|
numberBarAccessorData.sort(function (a, b) { return a - b; });
|
|
760
772
|
var scaledData = numberBarAccessorData.map(function (datum) { return positionScale.scale(datum); });
|
|
761
773
|
var barAccessorDataPairs = d3.pairs(scaledData);
|
|
@@ -11,7 +11,7 @@ var Utils = require("../utils");
|
|
|
11
11
|
var barPlot_1 = require("./barPlot");
|
|
12
12
|
var plot_1 = require("./plot");
|
|
13
13
|
var ClusteredBar = /** @class */ (function (_super) {
|
|
14
|
-
|
|
14
|
+
tslib_1.__extends(ClusteredBar, _super);
|
|
15
15
|
/**
|
|
16
16
|
* A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars.
|
|
17
17
|
* On a vertical ClusteredBar Plot, the bars with the same X value are grouped.
|
package/build/src/plots/index.js
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
var tslib_1 = require("tslib");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
tslib_1.__exportStar(require("./areaPlot"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./barPlot"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./commons"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./clusteredBarPlot"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./linePlot"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./piePlot"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./rectanglePlot"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./scatterPlot"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./segmentPlot"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./stackedAreaPlot"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./stackedBarPlot"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./waterfallPlot"), exports);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
import * as d3 from "d3";
|
|
6
|
-
import * as d3Shape from "d3-shape";
|
|
7
6
|
import { Dataset } from "../core/dataset";
|
|
8
7
|
import { AttributeToProjector, IAccessor, IRangeProjector, Point, Projector } from "../core/interfaces";
|
|
9
8
|
import * as Drawers from "../drawers";
|
|
@@ -30,7 +29,7 @@ export declare const CurveName: {
|
|
|
30
29
|
cardinalClosed: "cardinalClosed";
|
|
31
30
|
monotone: "monotone";
|
|
32
31
|
};
|
|
33
|
-
export
|
|
32
|
+
export type CurveName = keyof typeof CurveName;
|
|
34
33
|
export declare class Line<X> extends XYPlot<X, number> {
|
|
35
34
|
private _curve;
|
|
36
35
|
private _autorangeSmooth;
|
|
@@ -141,7 +140,7 @@ export declare class Line<X> extends XYPlot<X, number> {
|
|
|
141
140
|
* @returns {Line<[number,number]>}
|
|
142
141
|
* @private
|
|
143
142
|
*/
|
|
144
|
-
protected _d3LineFactory(dataset: Dataset, xProjector?: IAccessor<any>, yProjector?: IAccessor<any>):
|
|
143
|
+
protected _d3LineFactory(dataset: Dataset, xProjector?: IAccessor<any>, yProjector?: IAccessor<any>): d3.Line<any>;
|
|
145
144
|
protected _getCurveFactory(): d3.CurveFactory | d3.CurveFactoryLineOnly;
|
|
146
145
|
/**
|
|
147
146
|
* Line plots represent each dataset with a single <path> element, so we wrap the dataset data in a single element array.
|
|
@@ -14,6 +14,7 @@ var lineDrawer_1 = require("../drawers/lineDrawer");
|
|
|
14
14
|
var Scales = require("../scales");
|
|
15
15
|
var quantitativeScale_1 = require("../scales/quantitativeScale");
|
|
16
16
|
var Utils = require("../utils");
|
|
17
|
+
var d3ShapeUtils_1 = require("../utils/d3ShapeUtils");
|
|
17
18
|
var makeEnum_1 = require("../utils/makeEnum");
|
|
18
19
|
var Plots = require("./");
|
|
19
20
|
var plot_1 = require("./plot");
|
|
@@ -52,7 +53,7 @@ exports.CurveName = (0, makeEnum_1.makeEnum)([
|
|
|
52
53
|
"monotone",
|
|
53
54
|
]);
|
|
54
55
|
var Line = /** @class */ (function (_super) {
|
|
55
|
-
|
|
56
|
+
tslib_1.__extends(Line, _super);
|
|
56
57
|
/**
|
|
57
58
|
* A Line Plot draws line segments starting from the first data point to the next.
|
|
58
59
|
*
|
|
@@ -356,7 +357,7 @@ var Line = /** @class */ (function (_super) {
|
|
|
356
357
|
var positionY = yProjector(d, i, dataset);
|
|
357
358
|
return Utils.Math.isValidNumber(positionX) && Utils.Math.isValidNumber(positionY);
|
|
358
359
|
};
|
|
359
|
-
return d3.line()
|
|
360
|
+
return (0, d3ShapeUtils_1.withFullPrecision)(d3.line())
|
|
360
361
|
.x(function (innerDatum, innerIndex) { return xProjector(innerDatum, innerIndex, dataset); })
|
|
361
362
|
.y(function (innerDatum, innerIndex) { return yProjector(innerDatum, innerIndex, dataset); })
|
|
362
363
|
.curve(this._getCurveFactory())
|
|
@@ -15,10 +15,11 @@ var Utils = require("../utils");
|
|
|
15
15
|
var arcDrawer_1 = require("../drawers/arcDrawer");
|
|
16
16
|
var arcOutlineDrawer_1 = require("../drawers/arcOutlineDrawer");
|
|
17
17
|
var drawer_1 = require("../drawers/drawer");
|
|
18
|
+
var d3ShapeUtils_1 = require("../utils/d3ShapeUtils");
|
|
18
19
|
var windowUtils_1 = require("../utils/windowUtils");
|
|
19
20
|
var plot_1 = require("./plot");
|
|
20
21
|
var Pie = /** @class */ (function (_super) {
|
|
21
|
-
|
|
22
|
+
tslib_1.__extends(Pie, _super);
|
|
22
23
|
/**
|
|
23
24
|
* @constructor
|
|
24
25
|
*/
|
|
@@ -54,6 +55,7 @@ var Pie = /** @class */ (function (_super) {
|
|
|
54
55
|
if (this.outerRadius().scale != null) {
|
|
55
56
|
this.outerRadius().scale.range([0, radiusLimit]);
|
|
56
57
|
}
|
|
58
|
+
this._updateExtents();
|
|
57
59
|
return this;
|
|
58
60
|
};
|
|
59
61
|
Pie.prototype.addDataset = function (dataset) {
|
|
@@ -211,7 +213,7 @@ var Pie = /** @class */ (function (_super) {
|
|
|
211
213
|
var innerRadiusAccessor = plot_1.Plot._scaledAccessor(this.innerRadius());
|
|
212
214
|
var outerRadiusAccessor = plot_1.Plot._scaledAccessor(this.outerRadius());
|
|
213
215
|
attrToProjector["d"] = function (datum, index, ds) {
|
|
214
|
-
return d3.arc().innerRadius(innerRadiusAccessor(datum, index, ds))
|
|
216
|
+
return (0, d3ShapeUtils_1.withFullPrecision)(d3.arc()).innerRadius(innerRadiusAccessor(datum, index, ds))
|
|
215
217
|
.outerRadius(outerRadiusAccessor(datum, index, ds))
|
|
216
218
|
.startAngle(_this._startAngles[index])
|
|
217
219
|
.endAngle(_this._endAngles[index])(datum, index);
|
|
@@ -17,7 +17,7 @@ export declare const Renderer: {
|
|
|
17
17
|
canvas: "canvas";
|
|
18
18
|
svg: "svg";
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type Renderer = keyof typeof Renderer;
|
|
21
21
|
export declare class Plot extends Component {
|
|
22
22
|
static OPTIMIZE_MEMOIZE_PROJECTORS: boolean;
|
|
23
23
|
static getTotalDrawTime(data: any[], drawSteps: Drawers.DrawStep[]): number;
|
|
@@ -93,7 +93,7 @@ export declare class Plot extends Component {
|
|
|
93
93
|
* registered by the user. By default, only attrs are passed to the
|
|
94
94
|
* _generateDrawStep's attrToProjector; properties are not.
|
|
95
95
|
*/
|
|
96
|
-
protected _propertyBindings:
|
|
96
|
+
protected _propertyBindings: Map<string, Plots.IAccessorScaleBinding<any, any>>;
|
|
97
97
|
/**
|
|
98
98
|
* Mapping from property names to the extents ([min, max]) values that that
|
|
99
99
|
* property takes on.
|
|
@@ -306,6 +306,8 @@ export declare class Plot extends Component {
|
|
|
306
306
|
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
307
307
|
* or undefined if no {Plots.PlotEntity} can be found.
|
|
308
308
|
*
|
|
309
|
+
* If several Entities are equally near, returns the one drawn last (the last Dataset, then the last datum).
|
|
310
|
+
*
|
|
309
311
|
* @param {Point} queryPoint
|
|
310
312
|
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
311
313
|
*/
|
package/build/src/plots/plot.js
CHANGED
|
@@ -20,7 +20,7 @@ var makeEnum_1 = require("../utils/makeEnum");
|
|
|
20
20
|
var deferredRenderer_1 = require("./deferredRenderer");
|
|
21
21
|
exports.Renderer = (0, makeEnum_1.makeEnum)(["svg", "canvas"]);
|
|
22
22
|
var Plot = /** @class */ (function (_super) {
|
|
23
|
-
|
|
23
|
+
tslib_1.__extends(Plot, _super);
|
|
24
24
|
/**
|
|
25
25
|
* A Plot draws some visualization of the inputted Datasets.
|
|
26
26
|
*
|
|
@@ -60,13 +60,13 @@ var Plot = /** @class */ (function (_super) {
|
|
|
60
60
|
_this._overflowHidden = true;
|
|
61
61
|
_this.addClass("plot");
|
|
62
62
|
_this._datasetToDrawer = new Utils.Map();
|
|
63
|
-
_this._attrBindings =
|
|
63
|
+
_this._attrBindings = new Map();
|
|
64
64
|
_this._includedValuesProvider = function (scale, ignoreAnchorState) {
|
|
65
65
|
return _this._includedValuesForScale(scale, ignoreAnchorState);
|
|
66
66
|
};
|
|
67
67
|
_this._renderCallback = function () { return _this.render(); };
|
|
68
68
|
_this._onDatasetUpdateCallback = function () { return _this._onDatasetUpdate(); };
|
|
69
|
-
_this._propertyBindings =
|
|
69
|
+
_this._propertyBindings = new Map();
|
|
70
70
|
var mainAnimator = new Animators.Easing().maxTotalDuration(Plot._ANIMATION_MAX_DURATION);
|
|
71
71
|
_this.animator(Plots.Animator.MAIN, mainAnimator);
|
|
72
72
|
_this.animator(Plots.Animator.RESET, new Animators.Null());
|
|
@@ -120,7 +120,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
120
120
|
};
|
|
121
121
|
Plot.prototype.setBounds = function (width, height, originX, originY) {
|
|
122
122
|
_super.prototype.setBounds.call(this, width, height, originX, originY);
|
|
123
|
-
this.
|
|
123
|
+
this._resetEntityStore();
|
|
124
124
|
if (this._canvas != null) {
|
|
125
125
|
if (this._bufferCanvas && !this._bufferCanvasValid) {
|
|
126
126
|
// copy current canvas to buffer 1:1
|
|
@@ -274,7 +274,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
274
274
|
};
|
|
275
275
|
Plot.prototype._generateAttrToProjector = function () {
|
|
276
276
|
var h = {};
|
|
277
|
-
this._attrBindings.
|
|
277
|
+
this._attrBindings.forEach(function (binding, attr) {
|
|
278
278
|
h[attr] = Plot._scaledAccessor(binding);
|
|
279
279
|
});
|
|
280
280
|
var propertyProjectors = this._propertyProjectors();
|
|
@@ -315,13 +315,13 @@ var Plot = /** @class */ (function (_super) {
|
|
|
315
315
|
*/
|
|
316
316
|
Plot.prototype._scales = function () {
|
|
317
317
|
var scales = [];
|
|
318
|
-
this._attrBindings.
|
|
318
|
+
this._attrBindings.forEach(function (binding, attr) {
|
|
319
319
|
var scale = binding.scale;
|
|
320
320
|
if (scale != null && scales.indexOf(scale) === -1) {
|
|
321
321
|
scales.push(scale);
|
|
322
322
|
}
|
|
323
323
|
});
|
|
324
|
-
this._propertyBindings.
|
|
324
|
+
this._propertyBindings.forEach(function (binding, property) {
|
|
325
325
|
var scale = binding.scale;
|
|
326
326
|
if (scale != null && scales.indexOf(scale) === -1) {
|
|
327
327
|
scales.push(scale);
|
|
@@ -375,7 +375,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
375
375
|
return [];
|
|
376
376
|
}
|
|
377
377
|
var includedValues = [];
|
|
378
|
-
this._attrBindings.
|
|
378
|
+
this._attrBindings.forEach(function (binding, attr) {
|
|
379
379
|
if (binding.scale === scale) {
|
|
380
380
|
var extents = _this.getExtentsForAttr(attr);
|
|
381
381
|
if (extents != null) {
|
|
@@ -383,7 +383,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
});
|
|
386
|
-
this._propertyBindings.
|
|
386
|
+
this._propertyBindings.forEach(function (binding, property) {
|
|
387
387
|
if (binding.scale === scale) {
|
|
388
388
|
var extents = _this.getExtentsForProperty(property);
|
|
389
389
|
if (extents != null) {
|
|
@@ -511,7 +511,7 @@ var Plot = /** @class */ (function (_super) {
|
|
|
511
511
|
var _loop_1 = function (datumIndex) {
|
|
512
512
|
var datum = data[datumIndex];
|
|
513
513
|
var position = _this._pixelPoint(datum, datumIndex, dataset);
|
|
514
|
-
if (Utils.Math.
|
|
514
|
+
if (!Utils.Math.isValidNumber(position.x) || !Utils.Math.isValidNumber(position.y)) {
|
|
515
515
|
return "continue";
|
|
516
516
|
}
|
|
517
517
|
var plot = _this;
|
|
@@ -685,6 +685,8 @@ var Plot = /** @class */ (function (_super) {
|
|
|
685
685
|
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
686
686
|
* or undefined if no {Plots.PlotEntity} can be found.
|
|
687
687
|
*
|
|
688
|
+
* If several Entities are equally near, returns the one drawn last (the last Dataset, then the last datum).
|
|
689
|
+
*
|
|
688
690
|
* @param {Point} queryPoint
|
|
689
691
|
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
690
692
|
*/
|
|
@@ -101,6 +101,11 @@ export declare class Rectangle<X, Y> extends XYPlot<X, Y> {
|
|
|
101
101
|
* @returns {PlotEntity[]} The PlotEntities at the particular point
|
|
102
102
|
*/
|
|
103
103
|
entitiesAt(point: Point): Plots.IPlotEntity[];
|
|
104
|
+
/**
|
|
105
|
+
* Undrawn rectangles stay in `_getDataToDraw` as null placeholders, so the
|
|
106
|
+
* drawer indexes each rectangle's element by its dataset index
|
|
107
|
+
*/
|
|
108
|
+
protected _buildLightweightPlotEntities(datasets: Dataset[]): Plots.ILightweightPlotEntity[];
|
|
104
109
|
protected _entityBounds(entity: Plots.IPlotEntity | Plots.ILightweightPlotEntity): Pick<DOMRect, "height" | "width" | "x" | "y">;
|
|
105
110
|
private _entityBBox;
|
|
106
111
|
/**
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.Rectangle = void 0;
|
|
8
8
|
var tslib_1 = require("tslib");
|
|
9
|
-
var d3 = require("d3");
|
|
10
9
|
var Typesettable = require("typesettable");
|
|
11
10
|
var Animators = require("../animators");
|
|
12
11
|
var Drawers = require("../drawers");
|
|
@@ -17,7 +16,7 @@ var Utils = require("../utils");
|
|
|
17
16
|
var plot_1 = require("./plot");
|
|
18
17
|
var xyPlot_1 = require("./xyPlot");
|
|
19
18
|
var Rectangle = /** @class */ (function (_super) {
|
|
20
|
-
|
|
19
|
+
tslib_1.__extends(Rectangle, _super);
|
|
21
20
|
/**
|
|
22
21
|
* A Rectangle Plot displays rectangles based on the data.
|
|
23
22
|
* The left and right edges of each rectangle can be set with x() and x2().
|
|
@@ -171,6 +170,17 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
171
170
|
return x <= point.x && point.x <= x + width && y <= point.y && point.y <= y + height;
|
|
172
171
|
});
|
|
173
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Undrawn rectangles stay in `_getDataToDraw` as null placeholders, so the
|
|
175
|
+
* drawer indexes each rectangle's element by its dataset index
|
|
176
|
+
*/
|
|
177
|
+
Rectangle.prototype._buildLightweightPlotEntities = function (datasets) {
|
|
178
|
+
var lightweightPlotEntities = _super.prototype._buildLightweightPlotEntities.call(this, datasets);
|
|
179
|
+
lightweightPlotEntities.forEach(function (lightweightPlotEntity) {
|
|
180
|
+
lightweightPlotEntity.validDatumIndex = lightweightPlotEntity.index;
|
|
181
|
+
});
|
|
182
|
+
return lightweightPlotEntities;
|
|
183
|
+
};
|
|
174
184
|
Rectangle.prototype._entityBounds = function (entity) {
|
|
175
185
|
var datum = entity.datum, index = entity.index, dataset = entity.dataset;
|
|
176
186
|
return this._entityBBox(datum, index, dataset, this._getAttrToProjector());
|
|
@@ -227,9 +237,9 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
227
237
|
}
|
|
228
238
|
else {
|
|
229
239
|
var accessor_1 = scale === this.x().scale ? this.x().accessor : this.y().accessor;
|
|
230
|
-
var accessorData =
|
|
240
|
+
var accessorData = Utils.Array.uniq(Utils.Array.flatten(this.datasets().map(function (dataset) {
|
|
231
241
|
return dataset.data().map(function (d, i) { return accessor_1(d, i, dataset).valueOf(); });
|
|
232
|
-
}))).
|
|
242
|
+
}))).map(function (value) { return +value; });
|
|
233
243
|
// Get the absolute difference between min and max
|
|
234
244
|
var min = Utils.Math.min(accessorData, 0);
|
|
235
245
|
var max = Utils.Math.max(accessorData, 0);
|
|
@@ -77,6 +77,17 @@ export declare class Scatter<X, Y> extends XYPlot<X, Y> {
|
|
|
77
77
|
* @returns {PlotEntity[]}
|
|
78
78
|
*/
|
|
79
79
|
entitiesAt(p: Point): IPlotEntity[];
|
|
80
|
+
/**
|
|
81
|
+
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
82
|
+
* or undefined if no {Plots.PlotEntity} can be found.
|
|
83
|
+
*
|
|
84
|
+
* If the query point is inside several Entities' bounding boxes, returns the
|
|
85
|
+
* one whose position is nearest, then the one drawn last.
|
|
86
|
+
*
|
|
87
|
+
* @param {Point} queryPoint
|
|
88
|
+
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
89
|
+
*/
|
|
90
|
+
entityNearest(queryPoint: Point): IPlotEntity;
|
|
80
91
|
/**
|
|
81
92
|
* Get whether bar labels are enabled.
|
|
82
93
|
*
|
|
@@ -20,7 +20,7 @@ var Plots = require("./");
|
|
|
20
20
|
var plot_1 = require("./plot");
|
|
21
21
|
var xyPlot_1 = require("./xyPlot");
|
|
22
22
|
var Scatter = /** @class */ (function (_super) {
|
|
23
|
-
|
|
23
|
+
tslib_1.__extends(Scatter, _super);
|
|
24
24
|
/**
|
|
25
25
|
* A Scatter Plot draws a symbol at each data point.
|
|
26
26
|
*
|
|
@@ -143,6 +143,33 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
143
143
|
return x - size / 2 <= p.x && p.x <= x + size / 2 && y - size / 2 <= p.y && p.y <= y + size / 2;
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* Returns the {Plots.PlotEntity} nearest to the query point,
|
|
148
|
+
* or undefined if no {Plots.PlotEntity} can be found.
|
|
149
|
+
*
|
|
150
|
+
* If the query point is inside several Entities' bounding boxes, returns the
|
|
151
|
+
* one whose position is nearest, then the one drawn last.
|
|
152
|
+
*
|
|
153
|
+
* @param {Point} queryPoint
|
|
154
|
+
* @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no {Plots.PlotEntity} can be found.
|
|
155
|
+
*/
|
|
156
|
+
Scatter.prototype.entityNearest = function (queryPoint) {
|
|
157
|
+
var containing = this._getEntityStore().entitiesInBounds({ x: queryPoint.x, y: queryPoint.y, width: 0, height: 0 });
|
|
158
|
+
if (containing.length === 0) {
|
|
159
|
+
return _super.prototype.entityNearest.call(this, queryPoint);
|
|
160
|
+
}
|
|
161
|
+
containing.sort(function (a, b) { return a.datasetIndex - b.datasetIndex || a.index - b.index; });
|
|
162
|
+
var nearest;
|
|
163
|
+
var minDistSquared = Infinity;
|
|
164
|
+
containing.forEach(function (entity) {
|
|
165
|
+
var distSquared = Utils.Math.distanceSquared(entity.position, queryPoint);
|
|
166
|
+
if (distSquared <= minDistSquared) {
|
|
167
|
+
nearest = entity;
|
|
168
|
+
minDistSquared = distSquared;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return this._lightweightPlotEntityToPlotEntity(nearest);
|
|
172
|
+
};
|
|
146
173
|
Scatter.prototype.labelsEnabled = function (enabled) {
|
|
147
174
|
if (enabled == null) {
|
|
148
175
|
return this._labelsEnabled;
|
|
@@ -166,7 +193,7 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
166
193
|
var labelArea = _a.labelArea;
|
|
167
194
|
labelArea.attr("class", null)
|
|
168
195
|
.classed(Scatter._LABEL_AREA_CLASS, true)
|
|
169
|
-
.classed("label-"
|
|
196
|
+
.classed("label-".concat(_this._labelFontSize), true);
|
|
170
197
|
});
|
|
171
198
|
return this.render();
|
|
172
199
|
}
|
|
@@ -185,7 +212,7 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
185
212
|
var drawer = _super.prototype._createNodesForDataset.call(this, dataset);
|
|
186
213
|
var labelArea = this._renderArea.append("g")
|
|
187
214
|
.classed(Scatter._LABEL_AREA_CLASS, true)
|
|
188
|
-
.classed("label-"
|
|
215
|
+
.classed("label-".concat(this._labelFontSize), true);
|
|
189
216
|
var context = new Typesettable.SvgContext(labelArea.node());
|
|
190
217
|
var measurer = new Typesettable.CacheMeasurer(context);
|
|
191
218
|
var writer = new Typesettable.Writer(measurer, context);
|
|
@@ -262,7 +289,7 @@ var Scatter = /** @class */ (function (_super) {
|
|
|
262
289
|
};
|
|
263
290
|
Scatter.prototype._createLabelContainer = function (labelArea, labelContainerOrigin, labelOrigin, measurement) {
|
|
264
291
|
var labelContainer = labelArea.append("g")
|
|
265
|
-
.attr("transform", "translate("
|
|
292
|
+
.attr("transform", "translate(".concat(labelContainerOrigin.x, ", ").concat(labelContainerOrigin.y, ")"));
|
|
266
293
|
labelContainer.classed("on-bar-label", true);
|
|
267
294
|
return labelContainer;
|
|
268
295
|
};
|
|
@@ -14,7 +14,7 @@ var windowUtils_1 = require("../utils/windowUtils");
|
|
|
14
14
|
var plot_1 = require("./plot");
|
|
15
15
|
var xyPlot_1 = require("./xyPlot");
|
|
16
16
|
var Segment = /** @class */ (function (_super) {
|
|
17
|
-
|
|
17
|
+
tslib_1.__extends(Segment, _super);
|
|
18
18
|
/**
|
|
19
19
|
* A Segment Plot displays line segments based on the data.
|
|
20
20
|
*
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.StackedArea = void 0;
|
|
8
8
|
var tslib_1 = require("tslib");
|
|
9
|
-
var d3 = require("d3");
|
|
10
9
|
var Animators = require("../animators");
|
|
11
10
|
var index_1 = require("../memoize/index");
|
|
12
11
|
var Utils = require("../utils");
|
|
13
12
|
var areaPlot_1 = require("./areaPlot");
|
|
14
13
|
var plot_1 = require("./plot");
|
|
15
14
|
var StackedArea = /** @class */ (function (_super) {
|
|
16
|
-
|
|
15
|
+
tslib_1.__extends(StackedArea, _super);
|
|
17
16
|
/**
|
|
18
17
|
* @constructor
|
|
19
18
|
*/
|
|
@@ -152,7 +151,7 @@ var StackedArea = /** @class */ (function (_super) {
|
|
|
152
151
|
var datasets = this.datasets();
|
|
153
152
|
var keyAccessor = this.x().accessor;
|
|
154
153
|
var keySets = datasets.map(function (dataset) {
|
|
155
|
-
return
|
|
154
|
+
return Utils.Array.uniq(dataset.data().map(function (datum, i) { return Utils.Stacking.normalizeKey(keyAccessor(datum, i, dataset)); }));
|
|
156
155
|
});
|
|
157
156
|
var domainKeys = StackedArea._domainKeys(datasets, keyAccessor);
|
|
158
157
|
if (keySets.some(function (keySet) { return keySet.length !== domainKeys.length; })) {
|
|
@@ -169,16 +168,16 @@ var StackedArea = /** @class */ (function (_super) {
|
|
|
169
168
|
* @return {string[]} An array of stringified keys
|
|
170
169
|
*/
|
|
171
170
|
StackedArea._domainKeys = function (datasets, keyAccessor) {
|
|
172
|
-
var domainKeys =
|
|
171
|
+
var domainKeys = new Set();
|
|
173
172
|
datasets.forEach(function (dataset) {
|
|
174
173
|
var data = dataset.data();
|
|
175
174
|
var dataLen = data.length;
|
|
176
175
|
for (var index = 0; index < dataLen; index++) {
|
|
177
176
|
var datum = data[index];
|
|
178
|
-
domainKeys.add(keyAccessor(datum, index, dataset));
|
|
177
|
+
domainKeys.add(String(keyAccessor(datum, index, dataset)));
|
|
179
178
|
}
|
|
180
179
|
});
|
|
181
|
-
return
|
|
180
|
+
return Array.from(domainKeys);
|
|
182
181
|
};
|
|
183
182
|
StackedArea.prototype._coordinateProjectors = function () {
|
|
184
183
|
var _this = this;
|
|
@@ -13,7 +13,7 @@ var Utils = require("../utils");
|
|
|
13
13
|
var barPlot_1 = require("./barPlot");
|
|
14
14
|
var plot_1 = require("./plot");
|
|
15
15
|
var StackedBar = /** @class */ (function (_super) {
|
|
16
|
-
|
|
16
|
+
tslib_1.__extends(StackedBar, _super);
|
|
17
17
|
/**
|
|
18
18
|
* A StackedBar Plot stacks bars across Datasets based on the primary value of the bars.
|
|
19
19
|
* On a vertical StackedBar Plot, the bars with the same X value are stacked.
|
|
@@ -65,7 +65,7 @@ var StackedBar = /** @class */ (function (_super) {
|
|
|
65
65
|
// clearing to remove outdated font-size classes
|
|
66
66
|
this._labelArea.attr("class", null)
|
|
67
67
|
.classed(barPlot_1.Bar._LABEL_AREA_CLASS, true)
|
|
68
|
-
.classed("label-"
|
|
68
|
+
.classed("label-".concat(this._labelFontSize), true);
|
|
69
69
|
}
|
|
70
70
|
_super.prototype.labelFontSize.call(this, fontSize);
|
|
71
71
|
return this;
|
|
@@ -76,7 +76,7 @@ var StackedBar = /** @class */ (function (_super) {
|
|
|
76
76
|
this._labelArea = this._renderArea
|
|
77
77
|
.append("g")
|
|
78
78
|
.classed(barPlot_1.Bar._LABEL_AREA_CLASS, true)
|
|
79
|
-
.classed("label-"
|
|
79
|
+
.classed("label-".concat(this._labelFontSize), true);
|
|
80
80
|
var context = new Typesettable.SvgContext(this._labelArea.node());
|
|
81
81
|
this._measurer = new Typesettable.CacheMeasurer(context);
|
|
82
82
|
this._writer = new Typesettable.Writer(this._measurer, context);
|
|
@@ -107,7 +107,7 @@ var StackedBar = /** @class */ (function (_super) {
|
|
|
107
107
|
? width > barThickness
|
|
108
108
|
: height > barThickness;
|
|
109
109
|
if (!textTooLong) {
|
|
110
|
-
var labelContainer = _this._labelArea.append("g").attr("transform", "translate("
|
|
110
|
+
var labelContainer = _this._labelArea.append("g").attr("transform", "translate(".concat(x, ", ").concat(y, ")"));
|
|
111
111
|
labelContainer.classed("stacked-bar-label", true);
|
|
112
112
|
var writeOptions = {
|
|
113
113
|
xAlign: "center",
|
|
@@ -10,7 +10,7 @@ var Utils = require("../utils");
|
|
|
10
10
|
var barPlot_1 = require("./barPlot");
|
|
11
11
|
var plot_1 = require("./plot");
|
|
12
12
|
var Waterfall = /** @class */ (function (_super) {
|
|
13
|
-
|
|
13
|
+
tslib_1.__extends(Waterfall, _super);
|
|
14
14
|
function Waterfall() {
|
|
15
15
|
var _this = _super.call(this) || this;
|
|
16
16
|
_this._connectorsEnabled = false;
|