plottable 3.9.0-dev-83-g29b5abab → 3.9.0-dev-86-g70f2b1ac
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/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/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/package.json +1 -1
- package/plottable.js +90 -63
- package/plottable.js.map +1 -1
|
@@ -10,4 +10,4 @@ exports.version = void 0;
|
|
|
10
10
|
* real version number during the dist phase for for npm module publishing. Modifying this line should
|
|
11
11
|
* be accompanied by modifying the "sed-version" task in package.json accordingly.
|
|
12
12
|
*/
|
|
13
|
-
exports.version = "3.9.0-dev-
|
|
13
|
+
exports.version = "3.9.0-dev-86-g70f2b1ac";
|
|
@@ -78,7 +78,14 @@ var Dispatcher = /** @class */ (function () {
|
|
|
78
78
|
}
|
|
79
79
|
var callbackSet = this._eventNameToCallbackSet[eventName];
|
|
80
80
|
if (callbackSet != null) {
|
|
81
|
-
|
|
81
|
+
// Interactions can resubscribe while handling an event, which Set.forEach would visit again
|
|
82
|
+
var callbacks_1 = [];
|
|
83
|
+
callbackSet.forEach(function (callback) { return callbacks_1.push(callback); });
|
|
84
|
+
callbacks_1.forEach(function (callback) {
|
|
85
|
+
if (callbackSet.has(callback)) {
|
|
86
|
+
callback.apply(callbackSet, args);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
82
89
|
}
|
|
83
90
|
};
|
|
84
91
|
return Dispatcher;
|
|
@@ -41,7 +41,14 @@ var Click = /** @class */ (function (_super) {
|
|
|
41
41
|
this._touchDispatcher.onTouchCancel(this._touchCancelCallback);
|
|
42
42
|
};
|
|
43
43
|
Click.prototype._unanchor = function () {
|
|
44
|
+
var _this = this;
|
|
44
45
|
_super.prototype._unanchor.call(this);
|
|
46
|
+
// Preserve a press through synchronous renderTo(), but discard it if its release can be missed.
|
|
47
|
+
Promise.resolve().then(function () {
|
|
48
|
+
if (!_this._isAnchored) {
|
|
49
|
+
_this._clickedDown = false;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
45
52
|
this._mouseDispatcher.offMouseDown(this._mouseDownCallback);
|
|
46
53
|
this._mouseDispatcher.offMouseUp(this._mouseUpCallback);
|
|
47
54
|
this._mouseDispatcher.offDblClick(this._dblClickCallback);
|
|
@@ -45,7 +45,13 @@ var Drag = /** @class */ (function (_super) {
|
|
|
45
45
|
this._touchDispatcher.onTouchEnd(this._touchEndCallback);
|
|
46
46
|
};
|
|
47
47
|
Drag.prototype._unanchor = function () {
|
|
48
|
+
var _this = this;
|
|
48
49
|
_super.prototype._unanchor.call(this);
|
|
50
|
+
Promise.resolve().then(function () {
|
|
51
|
+
if (!_this._isAnchored) {
|
|
52
|
+
_this._dragging = false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
49
55
|
this._mouseDispatcher.offMouseDown(this._mouseDownCallback);
|
|
50
56
|
this._mouseDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
51
57
|
this._mouseDispatcher.offMouseUp(this._mouseUpCallback);
|
|
@@ -6,7 +6,8 @@ import { Component } from "../components/component";
|
|
|
6
6
|
import { Point } from "../core/interfaces";
|
|
7
7
|
export declare class Interaction {
|
|
8
8
|
private _anchorCallback;
|
|
9
|
-
private
|
|
9
|
+
private _detachCallback;
|
|
10
|
+
protected _isAnchored: boolean;
|
|
10
11
|
private _enabled;
|
|
11
12
|
protected _componentAttachedTo: Component;
|
|
12
13
|
/**
|
|
@@ -8,7 +8,15 @@ exports.Interaction = void 0;
|
|
|
8
8
|
var Interaction = /** @class */ (function () {
|
|
9
9
|
function Interaction() {
|
|
10
10
|
var _this = this;
|
|
11
|
-
this._anchorCallback = function (component) {
|
|
11
|
+
this._anchorCallback = function (component) {
|
|
12
|
+
_this._detachCallback();
|
|
13
|
+
_this._anchor(component);
|
|
14
|
+
};
|
|
15
|
+
this._detachCallback = function () {
|
|
16
|
+
if (_this._isAnchored) {
|
|
17
|
+
_this._unanchor();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
12
20
|
this._enabled = true;
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
@@ -87,6 +95,7 @@ var Interaction = /** @class */ (function () {
|
|
|
87
95
|
Interaction.prototype._connect = function () {
|
|
88
96
|
if (this.enabled() && this._componentAttachedTo != null && !this._isAnchored) {
|
|
89
97
|
this._componentAttachedTo.onAnchor(this._anchorCallback);
|
|
98
|
+
this._componentAttachedTo.onDetach(this._detachCallback);
|
|
90
99
|
}
|
|
91
100
|
};
|
|
92
101
|
Interaction.prototype._disconnect = function () {
|
|
@@ -95,6 +104,7 @@ var Interaction = /** @class */ (function () {
|
|
|
95
104
|
}
|
|
96
105
|
if (this._componentAttachedTo != null) {
|
|
97
106
|
this._componentAttachedTo.offAnchor(this._anchorCallback);
|
|
107
|
+
this._componentAttachedTo.offDetach(this._detachCallback);
|
|
98
108
|
}
|
|
99
109
|
};
|
|
100
110
|
return Interaction;
|
|
@@ -30,7 +30,14 @@ var Key = /** @class */ (function (_super) {
|
|
|
30
30
|
this._keyDispatcher.onKeyUp(this._keyUpCallback);
|
|
31
31
|
};
|
|
32
32
|
Key.prototype._unanchor = function () {
|
|
33
|
+
var _this = this;
|
|
33
34
|
_super.prototype._unanchor.call(this);
|
|
35
|
+
// Preserve held keys through synchronous renderTo(), but discard them if keyup can be missed.
|
|
36
|
+
Promise.resolve().then(function () {
|
|
37
|
+
if (!_this._isAnchored) {
|
|
38
|
+
_this._downedKeys = new Utils.Set();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
34
41
|
this._positionDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
35
42
|
this._positionDispatcher = null;
|
|
36
43
|
this._keyDispatcher.offKeyDown(this._keyDownCallback);
|
|
@@ -140,7 +140,13 @@ var PanZoom = /** @class */ (function (_super) {
|
|
|
140
140
|
this._touchDispatcher.onTouchCancel(this._touchCancelCallback);
|
|
141
141
|
};
|
|
142
142
|
PanZoom.prototype._unanchor = function () {
|
|
143
|
+
var _this = this;
|
|
143
144
|
_super.prototype._unanchor.call(this);
|
|
145
|
+
Promise.resolve().then(function () {
|
|
146
|
+
if (!_this._isAnchored) {
|
|
147
|
+
_this._touchIds.clear();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
144
150
|
this._mouseDispatcher.offWheel(this._wheelCallback);
|
|
145
151
|
this._mouseDispatcher = null;
|
|
146
152
|
this._touchDispatcher.offTouchStart(this._touchStartCallback);
|
|
@@ -29,7 +29,14 @@ var Pointer = /** @class */ (function (_super) {
|
|
|
29
29
|
this._touchDispatcher.onTouchStart(this._touchStartCallback);
|
|
30
30
|
};
|
|
31
31
|
Pointer.prototype._unanchor = function () {
|
|
32
|
+
var _this = this;
|
|
32
33
|
_super.prototype._unanchor.call(this);
|
|
34
|
+
// Preserve hover through synchronous renderTo(), but discard state if pointer events can be missed.
|
|
35
|
+
Promise.resolve().then(function () {
|
|
36
|
+
if (!_this._isAnchored) {
|
|
37
|
+
_this._overComponent = false;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
33
40
|
this._mouseDispatcher.offMouseMove(this._mouseMoveCallback);
|
|
34
41
|
this._mouseDispatcher = null;
|
|
35
42
|
this._touchDispatcher.offTouchStart(this._touchStartCallback);
|
|
@@ -20,6 +20,7 @@ var Category = /** @class */ (function (_super) {
|
|
|
20
20
|
*/
|
|
21
21
|
function Category() {
|
|
22
22
|
var _this = _super.call(this) || this;
|
|
23
|
+
_this._domain = [];
|
|
23
24
|
_this._range = [0, 1];
|
|
24
25
|
_this._d3Scale = d3.scaleBand();
|
|
25
26
|
_this._d3Scale.range(TRANSFORMATION_SPACE);
|
|
@@ -69,7 +70,7 @@ var Category = /** @class */ (function (_super) {
|
|
|
69
70
|
var normalizedDomain = domain.map(function (d) { return _this._d3Scale(d) + rangeBand / 2; });
|
|
70
71
|
var domainStart = d3.bisect(normalizedDomain, domainStartNormalized);
|
|
71
72
|
var domainEnd = d3.bisect(normalizedDomain, domainEndNormalized);
|
|
72
|
-
return
|
|
73
|
+
return this._domain.slice(domainStart, domainEnd);
|
|
73
74
|
};
|
|
74
75
|
Category.prototype.range = function (values) {
|
|
75
76
|
return _super.prototype.range.call(this, values);
|
|
@@ -127,8 +128,9 @@ var Category = /** @class */ (function (_super) {
|
|
|
127
128
|
return this;
|
|
128
129
|
};
|
|
129
130
|
Category.prototype.scale = function (value) {
|
|
131
|
+
// Accessors read untyped data, so values can be numbers, and 1 and "1" must share a band
|
|
130
132
|
// Determine the middle of the range band for the value
|
|
131
|
-
var untransformed = this._d3Scale(value) + this._d3Scale.bandwidth() / 2;
|
|
133
|
+
var untransformed = this._d3Scale(String(value)) + this._d3Scale.bandwidth() / 2;
|
|
132
134
|
// Convert to screen space
|
|
133
135
|
return this._d3TransformationScale(untransformed);
|
|
134
136
|
};
|
|
@@ -169,10 +171,11 @@ var Category = /** @class */ (function (_super) {
|
|
|
169
171
|
};
|
|
170
172
|
Category.prototype._backingScaleDomain = function (values) {
|
|
171
173
|
if (values == null) {
|
|
172
|
-
return this.
|
|
174
|
+
return this._domain.slice();
|
|
173
175
|
}
|
|
174
176
|
else {
|
|
175
|
-
this.
|
|
177
|
+
this._domain = Utils.Array.uniq(values);
|
|
178
|
+
this._d3Scale.domain(this._domain.map(String));
|
|
176
179
|
this._setBands();
|
|
177
180
|
return this;
|
|
178
181
|
}
|
|
@@ -7,9 +7,9 @@ export declare class Color extends Scale<string, string> {
|
|
|
7
7
|
private static _LOOP_LIGHTEN_FACTOR;
|
|
8
8
|
private static _MAXIMUM_COLORS_FROM_CSS;
|
|
9
9
|
private static _plottableColorCache;
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
10
|
+
private _domain;
|
|
11
|
+
private _domainIndices;
|
|
12
|
+
private _range;
|
|
13
13
|
/**
|
|
14
14
|
* A Color Scale maps string values to color hex values expressed as a string.
|
|
15
15
|
*
|
|
@@ -33,6 +33,7 @@ export declare class Color extends Scale<string, string> {
|
|
|
33
33
|
* @returns {string}
|
|
34
34
|
*/
|
|
35
35
|
scale(value: string): string;
|
|
36
|
+
private _domainIndex;
|
|
36
37
|
protected _getDomain(): string[];
|
|
37
38
|
protected _backingScaleDomain(): string[];
|
|
38
39
|
protected _backingScaleDomain(values: string[]): this;
|
|
@@ -9,41 +9,6 @@ var tslib_1 = require("tslib");
|
|
|
9
9
|
var d3 = require("d3");
|
|
10
10
|
var Utils = require("../utils");
|
|
11
11
|
var scale_1 = require("./scale");
|
|
12
|
-
/**
|
|
13
|
-
* Workaround for bad d3 behavior.
|
|
14
|
-
*
|
|
15
|
-
* d3's color scales, which are oridinal scales, have side-effects when invoked.
|
|
16
|
-
* When you call the `scale(value)` as a function, it will implicitly add new
|
|
17
|
-
* values to the domain.
|
|
18
|
-
*
|
|
19
|
-
* These side-effects cause us to rely on looking up the current scale state
|
|
20
|
-
* with the `.domain()` and `.range()` methods. However, these methods have poor
|
|
21
|
-
* performance implications since they will always slice their internal values
|
|
22
|
-
* before returning. Inside the inner render loop of color scatter plot points,
|
|
23
|
-
* these slices add up.
|
|
24
|
-
*/
|
|
25
|
-
var ImplicitSeriesTracker = /** @class */ (function () {
|
|
26
|
-
function ImplicitSeriesTracker() {
|
|
27
|
-
this.count = 0;
|
|
28
|
-
this.tracker = new Map();
|
|
29
|
-
}
|
|
30
|
-
ImplicitSeriesTracker.prototype.getIndex = function (value) {
|
|
31
|
-
if (this.tracker.has(value)) {
|
|
32
|
-
return this.tracker.get(value);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
var idx = this.count;
|
|
36
|
-
this.tracker.set(value, idx);
|
|
37
|
-
this.count += 1;
|
|
38
|
-
return idx;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
ImplicitSeriesTracker.prototype.clear = function () {
|
|
42
|
-
this.count = 0;
|
|
43
|
-
this.tracker.clear();
|
|
44
|
-
};
|
|
45
|
-
return ImplicitSeriesTracker;
|
|
46
|
-
}());
|
|
47
12
|
// Preserve the public D3 4 palette names removed in D3 5.
|
|
48
13
|
var CATEGORY20 = [
|
|
49
14
|
"#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
|
|
@@ -75,43 +40,41 @@ var Color = /** @class */ (function (_super) {
|
|
|
75
40
|
*/
|
|
76
41
|
function Color(scaleType) {
|
|
77
42
|
var _this = _super.call(this) || this;
|
|
78
|
-
|
|
79
|
-
_this.
|
|
80
|
-
|
|
81
|
-
var scale;
|
|
43
|
+
_this._domain = [];
|
|
44
|
+
_this._domainIndices = new Map();
|
|
45
|
+
var range;
|
|
82
46
|
switch (scaleType) {
|
|
83
47
|
case null:
|
|
84
48
|
case undefined:
|
|
85
49
|
if (Color._plottableColorCache == null) {
|
|
86
50
|
Color._plottableColorCache = Color._getPlottableColors();
|
|
87
51
|
}
|
|
88
|
-
|
|
52
|
+
range = Color._plottableColorCache;
|
|
89
53
|
break;
|
|
90
54
|
case "Category10":
|
|
91
55
|
case "category10":
|
|
92
56
|
case "10":
|
|
93
|
-
|
|
57
|
+
range = d3.schemeCategory10;
|
|
94
58
|
break;
|
|
95
59
|
case "Category20":
|
|
96
60
|
case "category20":
|
|
97
61
|
case "20":
|
|
98
|
-
|
|
62
|
+
range = CATEGORY20;
|
|
99
63
|
break;
|
|
100
64
|
case "Category20b":
|
|
101
65
|
case "category20b":
|
|
102
66
|
case "20b":
|
|
103
|
-
|
|
67
|
+
range = CATEGORY20B;
|
|
104
68
|
break;
|
|
105
69
|
case "Category20c":
|
|
106
70
|
case "category20c":
|
|
107
71
|
case "20c":
|
|
108
|
-
|
|
72
|
+
range = CATEGORY20C;
|
|
109
73
|
break;
|
|
110
74
|
default:
|
|
111
75
|
throw new Error("Unsupported ColorScale type");
|
|
112
76
|
}
|
|
113
|
-
_this.
|
|
114
|
-
_this._rangeLength = _this._d3Scale.range().length;
|
|
77
|
+
_this._range = range.slice();
|
|
115
78
|
return _this;
|
|
116
79
|
}
|
|
117
80
|
Color.prototype.extentOfValues = function (values) {
|
|
@@ -151,34 +114,45 @@ var Color = /** @class */ (function (_super) {
|
|
|
151
114
|
* @returns {string}
|
|
152
115
|
*/
|
|
153
116
|
Color.prototype.scale = function (value) {
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
var numLooped = Math.floor(index / this.
|
|
117
|
+
var index = this._domainIndex(value);
|
|
118
|
+
var color = this._range[index % this._range.length];
|
|
119
|
+
var numLooped = Math.floor(index / this._range.length);
|
|
157
120
|
if (numLooped === 0) {
|
|
158
121
|
return color;
|
|
159
122
|
}
|
|
160
123
|
var modifyFactor = Math.log(numLooped * Color._LOOP_LIGHTEN_FACTOR + 1);
|
|
161
124
|
return Utils.Color.lightenColor(color, modifyFactor);
|
|
162
125
|
};
|
|
126
|
+
Color.prototype._domainIndex = function (value) {
|
|
127
|
+
// Accessors read untyped data, so values can be numbers, and 1 and "1" must share a color
|
|
128
|
+
var key = String(value);
|
|
129
|
+
var index = this._domainIndices.get(key);
|
|
130
|
+
if (index == null) {
|
|
131
|
+
index = this._domain.push(value) - 1;
|
|
132
|
+
this._domainIndices.set(key, index);
|
|
133
|
+
}
|
|
134
|
+
return index;
|
|
135
|
+
};
|
|
163
136
|
Color.prototype._getDomain = function () {
|
|
164
137
|
return this._backingScaleDomain();
|
|
165
138
|
};
|
|
166
139
|
Color.prototype._backingScaleDomain = function (values) {
|
|
140
|
+
var _this = this;
|
|
167
141
|
if (values == null) {
|
|
168
|
-
return this.
|
|
142
|
+
return this._domain.slice();
|
|
169
143
|
}
|
|
170
144
|
else {
|
|
171
|
-
this.
|
|
172
|
-
this.
|
|
145
|
+
this._domain = [];
|
|
146
|
+
this._domainIndices.clear();
|
|
147
|
+
values.forEach(function (value) { return _this._domainIndex(value); });
|
|
173
148
|
return this;
|
|
174
149
|
}
|
|
175
150
|
};
|
|
176
151
|
Color.prototype._getRange = function () {
|
|
177
|
-
return this.
|
|
152
|
+
return this._range.slice();
|
|
178
153
|
};
|
|
179
154
|
Color.prototype._setRange = function (values) {
|
|
180
|
-
this.
|
|
181
|
-
this._rangeLength = values.length;
|
|
155
|
+
this._range = values.slice();
|
|
182
156
|
};
|
|
183
157
|
Color._LOOP_LIGHTEN_FACTOR = 1.6;
|
|
184
158
|
// The maximum number of colors we are getting from CSS stylesheets
|