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
|
@@ -32,6 +32,9 @@ export type IDistanceFunction = (bounds: RTreeBounds, p: Point) => number;
|
|
|
32
32
|
export declare function createMinimizingNodePredicate<T>(point: Point, nearFn: IDistanceFunction, farFn: IDistanceFunction): (node: RTreeNode<T>) => QueryPredicateResult;
|
|
33
33
|
/**
|
|
34
34
|
* Create a `Array.sort` function from a query point and a distance function.
|
|
35
|
+
*
|
|
36
|
+
* Nodes are sorted from farthest to nearest. Ties are sorted from first
|
|
37
|
+
* inserted to last inserted.
|
|
35
38
|
*/
|
|
36
39
|
export declare function createNodeSort<T>(point: Point, distanceFn: IDistanceFunction): (a: RTreeNode<T>, b: RTreeNode<T>) => number;
|
|
37
40
|
/**
|
|
@@ -63,6 +66,9 @@ export declare class RTree<T> {
|
|
|
63
66
|
* Nearness is measured as the absolute distance from the query point to the
|
|
64
67
|
* nearest edge of the node bounds. If the node bounds contains the query
|
|
65
68
|
* point, the distance is 0.
|
|
69
|
+
*
|
|
70
|
+
* The results are equally near and sorted by insertion order, ending with
|
|
71
|
+
* the last inserted value.
|
|
66
72
|
*/
|
|
67
73
|
locateNearest(xy: Point): T[];
|
|
68
74
|
/**
|
|
@@ -72,7 +78,8 @@ export declare class RTree<T> {
|
|
|
72
78
|
* query's x point to the nearest edge of the node bounds. If the node
|
|
73
79
|
* bounds contains the query point, the distance is 0.
|
|
74
80
|
*
|
|
75
|
-
* The results are sorted by y-coordinate nearness
|
|
81
|
+
* The results are sorted by y-coordinate nearness, then by insertion
|
|
82
|
+
* order, ending with the nearest, last inserted value.
|
|
76
83
|
*/
|
|
77
84
|
locateNearestX(xy: Point): T[];
|
|
78
85
|
/**
|
|
@@ -82,7 +89,8 @@ export declare class RTree<T> {
|
|
|
82
89
|
* query's y point to the nearest edge of the node bounds. If the node
|
|
83
90
|
* bounds contains the query point, the distance is 0.
|
|
84
91
|
*
|
|
85
|
-
* The results are sorted by x-coordinate nearness
|
|
92
|
+
* The results are sorted by x-coordinate nearness, then by insertion
|
|
93
|
+
* order, ending with the nearest, last inserted value.
|
|
86
94
|
*/
|
|
87
95
|
locateNearestY(xy: Point): T[];
|
|
88
96
|
intersect(bounds: RTreeBounds): T[];
|
|
@@ -98,6 +106,7 @@ export declare class RTreeNode<T> {
|
|
|
98
106
|
entries: RTreeNode<T>[];
|
|
99
107
|
parent: RTreeNode<T>;
|
|
100
108
|
value: T;
|
|
109
|
+
insertionIndex: number;
|
|
101
110
|
constructor(leaf: boolean);
|
|
102
111
|
/**
|
|
103
112
|
* Returns `true` iff this node has more children than the `maxNodeChildren`
|
package/build/src/utils/rTree.js
CHANGED
|
@@ -76,10 +76,14 @@ function createMinimizingNodePredicate(point, nearFn, farFn) {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Create a `Array.sort` function from a query point and a distance function.
|
|
79
|
+
*
|
|
80
|
+
* Nodes are sorted from farthest to nearest. Ties are sorted from first
|
|
81
|
+
* inserted to last inserted.
|
|
79
82
|
*/
|
|
80
83
|
function createNodeSort(point, distanceFn) {
|
|
81
84
|
return function (a, b) {
|
|
82
|
-
|
|
85
|
+
var distanceDifference = distanceFn(b.bounds, point) - distanceFn(a.bounds, point);
|
|
86
|
+
return distanceDifference !== 0 ? distanceDifference : a.insertionIndex - b.insertionIndex;
|
|
83
87
|
};
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
@@ -119,6 +123,7 @@ var RTree = /** @class */ (function () {
|
|
|
119
123
|
}
|
|
120
124
|
// Insert new value node into leaf node
|
|
121
125
|
var valueNode = RTreeNode.valueNode(bounds, value);
|
|
126
|
+
valueNode.insertionIndex = this.size;
|
|
122
127
|
node.insert(valueNode);
|
|
123
128
|
this.size += 1;
|
|
124
129
|
// While node overflows, split and walk up
|
|
@@ -139,10 +144,14 @@ var RTree = /** @class */ (function () {
|
|
|
139
144
|
* Nearness is measured as the absolute distance from the query point to the
|
|
140
145
|
* nearest edge of the node bounds. If the node bounds contains the query
|
|
141
146
|
* point, the distance is 0.
|
|
147
|
+
*
|
|
148
|
+
* The results are equally near and sorted by insertion order, ending with
|
|
149
|
+
* the last inserted value.
|
|
142
150
|
*/
|
|
143
151
|
RTree.prototype.locateNearest = function (xy) {
|
|
144
152
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.distanceSquaredToNearEdge, RTreeBounds.distanceSquaredToFarEdge);
|
|
145
153
|
var nodes = this.queryNodes(predicate);
|
|
154
|
+
nodes.sort(function (a, b) { return a.insertionIndex - b.insertionIndex; });
|
|
146
155
|
return nodes.map(function (node) { return node.value; });
|
|
147
156
|
};
|
|
148
157
|
/**
|
|
@@ -152,7 +161,8 @@ var RTree = /** @class */ (function () {
|
|
|
152
161
|
* query's x point to the nearest edge of the node bounds. If the node
|
|
153
162
|
* bounds contains the query point, the distance is 0.
|
|
154
163
|
*
|
|
155
|
-
* The results are sorted by y-coordinate nearness
|
|
164
|
+
* The results are sorted by y-coordinate nearness, then by insertion
|
|
165
|
+
* order, ending with the nearest, last inserted value.
|
|
156
166
|
*/
|
|
157
167
|
RTree.prototype.locateNearestX = function (xy) {
|
|
158
168
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeX, RTreeBounds.absoluteDistanceToFarEdgeX);
|
|
@@ -167,7 +177,8 @@ var RTree = /** @class */ (function () {
|
|
|
167
177
|
* query's y point to the nearest edge of the node bounds. If the node
|
|
168
178
|
* bounds contains the query point, the distance is 0.
|
|
169
179
|
*
|
|
170
|
-
* The results are sorted by x-coordinate nearness
|
|
180
|
+
* The results are sorted by x-coordinate nearness, then by insertion
|
|
181
|
+
* order, ending with the nearest, last inserted value.
|
|
171
182
|
*/
|
|
172
183
|
RTree.prototype.locateNearestY = function (xy) {
|
|
173
184
|
var predicate = createMinimizingNodePredicate(xy, RTreeBounds.absoluteDistanceToNearEdgeY, RTreeBounds.absoluteDistanceToFarEdgeY);
|
|
@@ -242,6 +253,7 @@ var RTreeNode = /** @class */ (function () {
|
|
|
242
253
|
this.entries = [];
|
|
243
254
|
this.parent = null;
|
|
244
255
|
this.value = null;
|
|
256
|
+
this.insertionIndex = null;
|
|
245
257
|
}
|
|
246
258
|
RTreeNode.valueNode = function (bounds, value) {
|
|
247
259
|
var node = new RTreeNode(true);
|
|
@@ -129,6 +129,39 @@ function stackedExtent(stackingResult, keyAccessor, filter) {
|
|
|
129
129
|
var minStackExtent = Utils.Math.min(extents, 0);
|
|
130
130
|
return [nativeMath.min(minStackExtent, 0), nativeMath.max(0, maxStackExtent)];
|
|
131
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* A lodash `MapCache` backed by a `WeakMap`, so each cached string is
|
|
134
|
+
* released once its key object (such as a `Date`) is garbage collected.
|
|
135
|
+
* Primitive keys are never cached: a `WeakMap` cannot hold them, and
|
|
136
|
+
* `String()` on a primitive costs no more than a cache lookup.
|
|
137
|
+
*/
|
|
138
|
+
var WeakKeyCache = /** @class */ (function () {
|
|
139
|
+
function WeakKeyCache() {
|
|
140
|
+
this.map = new WeakMap();
|
|
141
|
+
}
|
|
142
|
+
WeakKeyCache.prototype.get = function (key) {
|
|
143
|
+
return this.isObjectKey(key) ? this.map.get(key) : undefined;
|
|
144
|
+
};
|
|
145
|
+
WeakKeyCache.prototype.has = function (key) {
|
|
146
|
+
return this.isObjectKey(key) && this.map.has(key);
|
|
147
|
+
};
|
|
148
|
+
WeakKeyCache.prototype.set = function (key, value) {
|
|
149
|
+
if (this.isObjectKey(key)) {
|
|
150
|
+
this.map.set(key, value);
|
|
151
|
+
}
|
|
152
|
+
return this;
|
|
153
|
+
};
|
|
154
|
+
WeakKeyCache.prototype.delete = function (key) {
|
|
155
|
+
return this.isObjectKey(key) && this.map.delete(key);
|
|
156
|
+
};
|
|
157
|
+
WeakKeyCache.prototype.clear = function () {
|
|
158
|
+
this.map = new WeakMap();
|
|
159
|
+
};
|
|
160
|
+
WeakKeyCache.prototype.isObjectKey = function (key) {
|
|
161
|
+
return typeof key === "object" && key !== null;
|
|
162
|
+
};
|
|
163
|
+
return WeakKeyCache;
|
|
164
|
+
}());
|
|
132
165
|
/**
|
|
133
166
|
* Normalizes a key used for stacking
|
|
134
167
|
*
|
|
@@ -138,3 +171,4 @@ function stackedExtent(stackingResult, keyAccessor, filter) {
|
|
|
138
171
|
exports.normalizeKey = (0, memoize_1.default)(function (key) {
|
|
139
172
|
return String(key);
|
|
140
173
|
});
|
|
174
|
+
exports.normalizeKey.cache = new WeakKeyCache();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plottable",
|
|
3
3
|
"description": "A modular charting library built on D3",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
"lint": "npm-run-all lint:tslint lint:eslint",
|
|
22
22
|
"lint:eslint": "grunt eslint",
|
|
23
23
|
"lint:tslint": "tslint --project tsconfig.json",
|
|
24
|
-
"start": "npm-run-all -p start:update-quicktests start:watch-tsc start:watch-quicktests start:webpack
|
|
24
|
+
"start": "npm-run-all -p start:update-quicktests start:watch-tsc start:watch-quicktests start:watch-webpack start:server",
|
|
25
|
+
"start:server": "grunt connect:server:keepalive",
|
|
25
26
|
"start:update-quicktests": "grunt update-quicktests",
|
|
26
27
|
"start:watch-quicktests": "grunt watch-quicktests",
|
|
27
28
|
"start:watch-tsc": "tsc -w -p .",
|
|
28
|
-
"start:webpack
|
|
29
|
+
"start:watch-webpack": "webpack --watch",
|
|
29
30
|
"test": "grunt test-local",
|
|
30
31
|
"test:ci": "grunt test-ci",
|
|
31
32
|
"test:browser": "node scripts/test-browser.js"
|
|
@@ -58,7 +59,6 @@
|
|
|
58
59
|
"tslint": "5.18.0",
|
|
59
60
|
"typescript": "~5.9.3",
|
|
60
61
|
"webpack": "2.6.1",
|
|
61
|
-
"webpack-dev-server": "2.11.1",
|
|
62
62
|
"webpack-merge": "^4.1.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
package/plottable.css
CHANGED
|
@@ -112,9 +112,10 @@
|
|
|
112
112
|
fill: #32313F;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
.plottable .
|
|
117
|
-
.plottable .
|
|
115
|
+
/* No label-12 rule, so consumer CSS can override the default size */
|
|
116
|
+
.plottable .tick-label-container text,
|
|
117
|
+
.plottable .bar-label-text-area text,
|
|
118
|
+
.plottable .scatter-label-text-area text {
|
|
118
119
|
font-size: 12px;
|
|
119
120
|
}
|
|
120
121
|
|