@deck.gl/aggregation-layers 8.7.0-alpha.2 → 8.7.0-alpha.9

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.
Files changed (70) hide show
  1. package/dist/dist.dev.js +2512 -1759
  2. package/dist/es5/aggregation-layer.js +163 -109
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +260 -240
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/contour-layer/contour-utils.js +86 -65
  7. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  8. package/dist/es5/contour-layer/marching-squares-codes.js +106 -181
  9. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  10. package/dist/es5/contour-layer/marching-squares.js +59 -56
  11. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +121 -85
  13. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js +119 -93
  15. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  17. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +167 -131
  18. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  19. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +322 -319
  20. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  21. package/dist/es5/grid-aggregation-layer.js +230 -202
  22. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  23. package/dist/es5/grid-layer/grid-layer.js +91 -61
  24. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  25. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +59 -24
  26. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  27. package/dist/es5/heatmap-layer/heatmap-layer.js +536 -515
  28. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  29. package/dist/es5/heatmap-layer/triangle-layer.js +91 -64
  30. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  31. package/dist/es5/hexagon-layer/hexagon-aggregator.js +77 -59
  32. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  33. package/dist/es5/hexagon-layer/hexagon-layer.js +164 -121
  34. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  35. package/dist/es5/index.js +12 -12
  36. package/dist/es5/index.js.map +1 -1
  37. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +193 -168
  38. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  39. package/dist/es5/screen-grid-layer/screen-grid-layer.js +250 -235
  40. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  41. package/dist/es5/utils/aggregation-operation-utils.js +31 -16
  42. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  43. package/dist/es5/utils/bin-sorter.js +198 -118
  44. package/dist/es5/utils/bin-sorter.js.map +1 -1
  45. package/dist/es5/utils/color-utils.js +10 -8
  46. package/dist/es5/utils/color-utils.js.map +1 -1
  47. package/dist/es5/utils/cpu-aggregator.js +342 -323
  48. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +18 -20
  50. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  51. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +547 -549
  52. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  53. package/dist/es5/utils/grid-aggregation-utils.js +44 -50
  54. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  55. package/dist/es5/utils/prop-utils.js +2 -2
  56. package/dist/es5/utils/prop-utils.js.map +1 -1
  57. package/dist/es5/utils/resource-utils.js +39 -32
  58. package/dist/es5/utils/resource-utils.js.map +1 -1
  59. package/dist/es5/utils/scale-utils.js +66 -36
  60. package/dist/es5/utils/scale-utils.js.map +1 -1
  61. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  62. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  63. package/dist/esm/heatmap-layer/heatmap-layer.js +4 -1
  64. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  65. package/dist/esm/index.js.map +1 -1
  66. package/dist.min.js +1 -1
  67. package/package.json +3 -3
  68. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +2 -3
  69. package/src/heatmap-layer/heatmap-layer.js +3 -1
  70. /package/src/{index.js → index.ts} +0 -0
@@ -7,16 +7,28 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
10
18
  var _binSorter = _interopRequireDefault(require("./bin-sorter"));
11
19
 
12
20
  var _scaleUtils = require("./scale-utils");
13
21
 
14
22
  var _aggregationOperationUtils = require("./aggregation-operation-utils");
15
23
 
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
+
16
28
  function nop() {}
17
29
 
18
- const dimensionSteps = ['getBins', 'getDomain', 'getScaleFunc'];
19
- const defaultDimensions = [{
30
+ var dimensionSteps = ['getBins', 'getDomain', 'getScaleFunc'];
31
+ var _defaultDimensions = [{
20
32
  key: 'fillColor',
21
33
  accessor: 'getFillColor',
22
34
  pickingInfo: 'colorValue',
@@ -118,10 +130,13 @@ const defaultDimensions = [{
118
130
  nullValue: -1
119
131
  }];
120
132
 
121
- const defaultGetCellSize = props => props.cellSize;
133
+ var defaultGetCellSize = function defaultGetCellSize(props) {
134
+ return props.cellSize;
135
+ };
122
136
 
123
- class CPUAggregator {
124
- constructor(opts) {
137
+ var CPUAggregator = function () {
138
+ function CPUAggregator(opts) {
139
+ (0, _classCallCheck2.default)(this, CPUAggregator);
125
140
  this.state = {
126
141
  layerData: {},
127
142
  dimensions: {}
@@ -131,366 +146,370 @@ class CPUAggregator {
131
146
  this._getCellSize = opts.getCellSize || defaultGetCellSize;
132
147
  this._getAggregator = opts.getAggregator;
133
148
 
134
- this._addDimension(opts.dimensions || defaultDimensions);
149
+ this._addDimension(opts.dimensions || _defaultDimensions);
135
150
  }
136
151
 
137
- static defaultDimensions() {
138
- return defaultDimensions;
139
- }
152
+ (0, _createClass2.default)(CPUAggregator, [{
153
+ key: "updateState",
154
+ value: function updateState(opts, aggregationParams) {
155
+ var oldProps = opts.oldProps,
156
+ props = opts.props,
157
+ changeFlags = opts.changeFlags;
158
+ this.updateGetValueFuncs(oldProps, props, changeFlags);
159
+ var reprojectNeeded = this.needsReProjectPoints(oldProps, props, changeFlags);
160
+ var aggregationDirty = false;
161
+
162
+ if (changeFlags.dataChanged || reprojectNeeded) {
163
+ this.getAggregatedData(props, aggregationParams);
164
+ aggregationDirty = true;
165
+ } else {
166
+ var dimensionChanges = this.getDimensionChanges(oldProps, props, changeFlags) || [];
167
+ dimensionChanges.forEach(function (f) {
168
+ return typeof f === 'function' && f();
169
+ });
170
+ aggregationDirty = true;
171
+ }
140
172
 
141
- updateState(opts, aggregationParams) {
142
- const {
143
- oldProps,
144
- props,
145
- changeFlags
146
- } = opts;
147
- this.updateGetValueFuncs(oldProps, props, changeFlags);
148
- const reprojectNeeded = this.needsReProjectPoints(oldProps, props, changeFlags);
149
- let aggregationDirty = false;
150
-
151
- if (changeFlags.dataChanged || reprojectNeeded) {
152
- this.getAggregatedData(props, aggregationParams);
153
- aggregationDirty = true;
154
- } else {
155
- const dimensionChanges = this.getDimensionChanges(oldProps, props, changeFlags) || [];
156
- dimensionChanges.forEach(f => typeof f === 'function' && f());
157
- aggregationDirty = true;
173
+ this.setState({
174
+ aggregationDirty: aggregationDirty
175
+ });
176
+ return this.state;
158
177
  }
159
-
160
- this.setState({
161
- aggregationDirty
162
- });
163
- return this.state;
164
- }
165
-
166
- setState(updateObject) {
167
- this.state = { ...this.state,
168
- ...updateObject
169
- };
170
- }
171
-
172
- setDimensionState(key, updateObject) {
173
- this.setState({
174
- dimensions: { ...this.state.dimensions,
175
- [key]: { ...this.state.dimensions[key],
176
- ...updateObject
177
- }
178
+ }, {
179
+ key: "setState",
180
+ value: function setState(updateObject) {
181
+ this.state = _objectSpread(_objectSpread({}, this.state), updateObject);
182
+ }
183
+ }, {
184
+ key: "setDimensionState",
185
+ value: function setDimensionState(key, updateObject) {
186
+ this.setState({
187
+ dimensions: _objectSpread(_objectSpread({}, this.state.dimensions), {}, (0, _defineProperty2.default)({}, key, _objectSpread(_objectSpread({}, this.state.dimensions[key]), updateObject)))
188
+ });
189
+ }
190
+ }, {
191
+ key: "normalizeResult",
192
+ value: function normalizeResult() {
193
+ var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
194
+
195
+ if (result.hexagons) {
196
+ return _objectSpread({
197
+ data: result.hexagons
198
+ }, result);
199
+ } else if (result.layerData) {
200
+ return _objectSpread({
201
+ data: result.layerData
202
+ }, result);
178
203
  }
179
- });
180
- }
181
204
 
182
- normalizeResult(result = {}) {
183
- if (result.hexagons) {
184
- return {
185
- data: result.hexagons,
186
- ...result
187
- };
188
- } else if (result.layerData) {
189
- return {
190
- data: result.layerData,
191
- ...result
205
+ return result;
206
+ }
207
+ }, {
208
+ key: "getAggregatedData",
209
+ value: function getAggregatedData(props, aggregationParams) {
210
+ var aggregator = this._getAggregator(props);
211
+
212
+ var result = aggregator(props, aggregationParams);
213
+ this.setState({
214
+ layerData: this.normalizeResult(result)
215
+ });
216
+ this.changeFlags = {
217
+ layerData: true
192
218
  };
219
+ this.getSortedBins(props);
193
220
  }
221
+ }, {
222
+ key: "updateGetValueFuncs",
223
+ value: function updateGetValueFuncs(oldProps, props, changeFlags) {
224
+ for (var key in this.dimensionUpdaters) {
225
+ var _this$dimensionUpdate = this.dimensionUpdaters[key].getBins.triggers,
226
+ value = _this$dimensionUpdate.value,
227
+ weight = _this$dimensionUpdate.weight,
228
+ aggregation = _this$dimensionUpdate.aggregation;
229
+ var getValue = props[value.prop];
230
+ var getValueChanged = this.needUpdateDimensionStep(this.dimensionUpdaters[key].getBins, oldProps, props, changeFlags);
231
+
232
+ if (getValueChanged) {
233
+ if (getValue) {
234
+ getValue = (0, _aggregationOperationUtils.wrapGetValueFunc)(getValue, {
235
+ data: props.data
236
+ });
237
+ } else {
238
+ getValue = (0, _aggregationOperationUtils.getValueFunc)(props[aggregation.prop], props[weight.prop], {
239
+ data: props.data
240
+ });
241
+ }
242
+ }
194
243
 
195
- return result;
196
- }
197
-
198
- getAggregatedData(props, aggregationParams) {
199
- const aggregator = this._getAggregator(props);
200
-
201
- const result = aggregator(props, aggregationParams);
202
- this.setState({
203
- layerData: this.normalizeResult(result)
204
- });
205
- this.changeFlags = {
206
- layerData: true
207
- };
208
- this.getSortedBins(props);
209
- }
210
-
211
- updateGetValueFuncs(oldProps, props, changeFlags) {
212
- for (const key in this.dimensionUpdaters) {
213
- const {
214
- value,
215
- weight,
216
- aggregation
217
- } = this.dimensionUpdaters[key].getBins.triggers;
218
- let getValue = props[value.prop];
219
- const getValueChanged = this.needUpdateDimensionStep(this.dimensionUpdaters[key].getBins, oldProps, props, changeFlags);
220
-
221
- if (getValueChanged) {
222
244
  if (getValue) {
223
- getValue = (0, _aggregationOperationUtils.wrapGetValueFunc)(getValue, {
224
- data: props.data
225
- });
226
- } else {
227
- getValue = (0, _aggregationOperationUtils.getValueFunc)(props[aggregation.prop], props[weight.prop], {
228
- data: props.data
245
+ this.setDimensionState(key, {
246
+ getValue: getValue
229
247
  });
230
248
  }
231
249
  }
250
+ }
251
+ }, {
252
+ key: "needsReProjectPoints",
253
+ value: function needsReProjectPoints(oldProps, props, changeFlags) {
254
+ return this._getCellSize(oldProps) !== this._getCellSize(props) || this._getAggregator(oldProps) !== this._getAggregator(props) || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPosition);
255
+ }
256
+ }, {
257
+ key: "addDimension",
258
+ value: function addDimension(dimensions) {
259
+ this._addDimension(dimensions);
260
+ }
261
+ }, {
262
+ key: "_addDimension",
263
+ value: function _addDimension() {
264
+ var _this = this;
265
+
266
+ var dimensions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
267
+ dimensions.forEach(function (dimension) {
268
+ var key = dimension.key;
269
+ _this.dimensionUpdaters[key] = _this.getDimensionUpdaters(dimension);
270
+ _this.state.dimensions[key] = {
271
+ getValue: null,
272
+ domain: null,
273
+ sortedBins: null,
274
+ scaleFunc: nop
275
+ };
276
+ });
277
+ }
278
+ }, {
279
+ key: "getDimensionUpdaters",
280
+ value: function getDimensionUpdaters(_ref) {
281
+ var key = _ref.key,
282
+ accessor = _ref.accessor,
283
+ pickingInfo = _ref.pickingInfo,
284
+ getBins = _ref.getBins,
285
+ getDomain = _ref.getDomain,
286
+ getScaleFunc = _ref.getScaleFunc,
287
+ nullValue = _ref.nullValue;
288
+ return {
289
+ key: key,
290
+ accessor: accessor,
291
+ pickingInfo: pickingInfo,
292
+ getBins: _objectSpread({
293
+ updater: this.getDimensionSortedBins
294
+ }, getBins),
295
+ getDomain: _objectSpread({
296
+ updater: this.getDimensionValueDomain
297
+ }, getDomain),
298
+ getScaleFunc: _objectSpread({
299
+ updater: this.getDimensionScale
300
+ }, getScaleFunc),
301
+ attributeAccessor: this.getSubLayerDimensionAttribute(key, nullValue)
302
+ };
303
+ }
304
+ }, {
305
+ key: "needUpdateDimensionStep",
306
+ value: function needUpdateDimensionStep(dimensionStep, oldProps, props, changeFlags) {
307
+ return Object.values(dimensionStep.triggers).some(function (item) {
308
+ if (item.updateTrigger) {
309
+ return changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged[item.updateTrigger]);
310
+ }
232
311
 
233
- if (getValue) {
234
- this.setDimensionState(key, {
235
- getValue
236
- });
237
- }
312
+ return oldProps[item.prop] !== props[item.prop];
313
+ });
238
314
  }
239
- }
315
+ }, {
316
+ key: "getDimensionChanges",
317
+ value: function getDimensionChanges(oldProps, props, changeFlags) {
318
+ var _this2 = this;
240
319
 
241
- needsReProjectPoints(oldProps, props, changeFlags) {
242
- return this._getCellSize(oldProps) !== this._getCellSize(props) || this._getAggregator(oldProps) !== this._getAggregator(props) || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPosition);
243
- }
320
+ var updaters = [];
244
321
 
245
- addDimension(dimensions) {
246
- this._addDimension(dimensions);
247
- }
322
+ var _loop = function _loop(key) {
323
+ var needUpdate = dimensionSteps.find(function (step) {
324
+ return _this2.needUpdateDimensionStep(_this2.dimensionUpdaters[key][step], oldProps, props, changeFlags);
325
+ });
248
326
 
249
- _addDimension(dimensions = []) {
250
- dimensions.forEach(dimension => {
251
- const {
252
- key
253
- } = dimension;
254
- this.dimensionUpdaters[key] = this.getDimensionUpdaters(dimension);
255
- this.state.dimensions[key] = {
256
- getValue: null,
257
- domain: null,
258
- sortedBins: null,
259
- scaleFunc: nop
327
+ if (needUpdate) {
328
+ updaters.push(_this2.dimensionUpdaters[key][needUpdate].updater.bind(_this2, props, _this2.dimensionUpdaters[key]));
329
+ }
260
330
  };
261
- });
262
- }
263
331
 
264
- getDimensionUpdaters({
265
- key,
266
- accessor,
267
- pickingInfo,
268
- getBins,
269
- getDomain,
270
- getScaleFunc,
271
- nullValue
272
- }) {
273
- return {
274
- key,
275
- accessor,
276
- pickingInfo,
277
- getBins: {
278
- updater: this.getDimensionSortedBins,
279
- ...getBins
280
- },
281
- getDomain: {
282
- updater: this.getDimensionValueDomain,
283
- ...getDomain
284
- },
285
- getScaleFunc: {
286
- updater: this.getDimensionScale,
287
- ...getScaleFunc
288
- },
289
- attributeAccessor: this.getSubLayerDimensionAttribute(key, nullValue)
290
- };
291
- }
292
-
293
- needUpdateDimensionStep(dimensionStep, oldProps, props, changeFlags) {
294
- return Object.values(dimensionStep.triggers).some(item => {
295
- if (item.updateTrigger) {
296
- return changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged[item.updateTrigger]);
332
+ for (var key in this.dimensionUpdaters) {
333
+ _loop(key);
297
334
  }
298
335
 
299
- return oldProps[item.prop] !== props[item.prop];
300
- });
301
- }
302
-
303
- getDimensionChanges(oldProps, props, changeFlags) {
304
- const updaters = [];
336
+ return updaters.length ? updaters : null;
337
+ }
338
+ }, {
339
+ key: "getUpdateTriggers",
340
+ value: function getUpdateTriggers(props) {
341
+ var _this3 = this;
342
+
343
+ var _updateTriggers = props.updateTriggers || {};
344
+
345
+ var updateTriggers = {};
346
+
347
+ var _loop2 = function _loop2(key) {
348
+ var accessor = _this3.dimensionUpdaters[key].accessor;
349
+ updateTriggers[accessor] = {};
350
+ dimensionSteps.forEach(function (step) {
351
+ Object.values(_this3.dimensionUpdaters[key][step].triggers).forEach(function (_ref2) {
352
+ var prop = _ref2.prop,
353
+ updateTrigger = _ref2.updateTrigger;
354
+
355
+ if (updateTrigger) {
356
+ var fromProp = _updateTriggers[updateTrigger];
357
+
358
+ if ((0, _typeof2.default)(fromProp) === 'object' && !Array.isArray(fromProp)) {
359
+ Object.assign(updateTriggers[accessor], fromProp);
360
+ } else if (fromProp !== undefined) {
361
+ updateTriggers[accessor][prop] = fromProp;
362
+ }
363
+ } else {
364
+ updateTriggers[accessor][prop] = props[prop];
365
+ }
366
+ });
367
+ });
368
+ };
305
369
 
306
- for (const key in this.dimensionUpdaters) {
307
- const needUpdate = dimensionSteps.find(step => this.needUpdateDimensionStep(this.dimensionUpdaters[key][step], oldProps, props, changeFlags));
370
+ for (var key in this.dimensionUpdaters) {
371
+ _loop2(key);
372
+ }
308
373
 
309
- if (needUpdate) {
310
- updaters.push(this.dimensionUpdaters[key][needUpdate].updater.bind(this, props, this.dimensionUpdaters[key]));
374
+ return updateTriggers;
375
+ }
376
+ }, {
377
+ key: "getSortedBins",
378
+ value: function getSortedBins(props) {
379
+ for (var key in this.dimensionUpdaters) {
380
+ this.getDimensionSortedBins(props, this.dimensionUpdaters[key]);
311
381
  }
312
382
  }
313
-
314
- return updaters.length ? updaters : null;
315
- }
316
-
317
- getUpdateTriggers(props) {
318
- const _updateTriggers = props.updateTriggers || {};
319
-
320
- const updateTriggers = {};
321
-
322
- for (const key in this.dimensionUpdaters) {
323
- const {
324
- accessor
325
- } = this.dimensionUpdaters[key];
326
- updateTriggers[accessor] = {};
327
- dimensionSteps.forEach(step => {
328
- Object.values(this.dimensionUpdaters[key][step].triggers).forEach(({
329
- prop,
330
- updateTrigger
331
- }) => {
332
- if (updateTrigger) {
333
- const fromProp = _updateTriggers[updateTrigger];
334
-
335
- if (typeof fromProp === 'object' && !Array.isArray(fromProp)) {
336
- Object.assign(updateTriggers[accessor], fromProp);
337
- } else if (fromProp !== undefined) {
338
- updateTriggers[accessor][prop] = fromProp;
339
- }
340
- } else {
341
- updateTriggers[accessor][prop] = props[prop];
342
- }
343
- });
383
+ }, {
384
+ key: "getDimensionSortedBins",
385
+ value: function getDimensionSortedBins(props, dimensionUpdater) {
386
+ var key = dimensionUpdater.key;
387
+ var getValue = this.state.dimensions[key].getValue;
388
+ var sortedBins = new _binSorter.default(this.state.layerData.data || [], {
389
+ getValue: getValue,
390
+ filterData: props._filterData
344
391
  });
392
+ this.setDimensionState(key, {
393
+ sortedBins: sortedBins
394
+ });
395
+ this.getDimensionValueDomain(props, dimensionUpdater);
345
396
  }
346
-
347
- return updateTriggers;
348
- }
349
-
350
- getSortedBins(props) {
351
- for (const key in this.dimensionUpdaters) {
352
- this.getDimensionSortedBins(props, this.dimensionUpdaters[key]);
397
+ }, {
398
+ key: "getDimensionValueDomain",
399
+ value: function getDimensionValueDomain(props, dimensionUpdater) {
400
+ var getDomain = dimensionUpdater.getDomain,
401
+ key = dimensionUpdater.key;
402
+ var _getDomain$triggers = getDomain.triggers,
403
+ lowerPercentile = _getDomain$triggers.lowerPercentile,
404
+ upperPercentile = _getDomain$triggers.upperPercentile,
405
+ scaleType = _getDomain$triggers.scaleType;
406
+ var valueDomain = this.state.dimensions[key].sortedBins.getValueDomainByScale(props[scaleType.prop], [props[lowerPercentile.prop], props[upperPercentile.prop]]);
407
+ this.setDimensionState(key, {
408
+ valueDomain: valueDomain
409
+ });
410
+ this.getDimensionScale(props, dimensionUpdater);
353
411
  }
354
- }
355
-
356
- getDimensionSortedBins(props, dimensionUpdater) {
357
- const {
358
- key
359
- } = dimensionUpdater;
360
- const {
361
- getValue
362
- } = this.state.dimensions[key];
363
- const sortedBins = new _binSorter.default(this.state.layerData.data || [], {
364
- getValue,
365
- filterData: props._filterData
366
- });
367
- this.setDimensionState(key, {
368
- sortedBins
369
- });
370
- this.getDimensionValueDomain(props, dimensionUpdater);
371
- }
372
-
373
- getDimensionValueDomain(props, dimensionUpdater) {
374
- const {
375
- getDomain,
376
- key
377
- } = dimensionUpdater;
378
- const {
379
- triggers: {
380
- lowerPercentile,
381
- upperPercentile,
382
- scaleType
412
+ }, {
413
+ key: "getDimensionScale",
414
+ value: function getDimensionScale(props, dimensionUpdater) {
415
+ var key = dimensionUpdater.key,
416
+ getScaleFunc = dimensionUpdater.getScaleFunc,
417
+ getDomain = dimensionUpdater.getDomain;
418
+ var _getScaleFunc$trigger = getScaleFunc.triggers,
419
+ domain = _getScaleFunc$trigger.domain,
420
+ range = _getScaleFunc$trigger.range;
421
+ var scaleType = getDomain.triggers.scaleType;
422
+ var onSet = getScaleFunc.onSet;
423
+ var dimensionRange = props[range.prop];
424
+ var dimensionDomain = props[domain.prop] || this.state.dimensions[key].valueDomain;
425
+ var getScaleFunction = (0, _scaleUtils.getScaleFunctionByScaleType)(scaleType && props[scaleType.prop]);
426
+ var scaleFunc = getScaleFunction(dimensionDomain, dimensionRange);
427
+
428
+ if ((0, _typeof2.default)(onSet) === 'object' && typeof props[onSet.props] === 'function') {
429
+ props[onSet.props](scaleFunc.domain());
383
430
  }
384
- } = getDomain;
385
- const valueDomain = this.state.dimensions[key].sortedBins.getValueDomainByScale(props[scaleType.prop], [props[lowerPercentile.prop], props[upperPercentile.prop]]);
386
- this.setDimensionState(key, {
387
- valueDomain
388
- });
389
- this.getDimensionScale(props, dimensionUpdater);
390
- }
391
431
 
392
- getDimensionScale(props, dimensionUpdater) {
393
- const {
394
- key,
395
- getScaleFunc,
396
- getDomain
397
- } = dimensionUpdater;
398
- const {
399
- domain,
400
- range
401
- } = getScaleFunc.triggers;
402
- const {
403
- scaleType
404
- } = getDomain.triggers;
405
- const {
406
- onSet
407
- } = getScaleFunc;
408
- const dimensionRange = props[range.prop];
409
- const dimensionDomain = props[domain.prop] || this.state.dimensions[key].valueDomain;
410
- const getScaleFunction = (0, _scaleUtils.getScaleFunctionByScaleType)(scaleType && props[scaleType.prop]);
411
- const scaleFunc = getScaleFunction(dimensionDomain, dimensionRange);
412
-
413
- if (typeof onSet === 'object' && typeof props[onSet.props] === 'function') {
414
- props[onSet.props](scaleFunc.domain());
432
+ this.setDimensionState(key, {
433
+ scaleFunc: scaleFunc
434
+ });
415
435
  }
436
+ }, {
437
+ key: "getSubLayerDimensionAttribute",
438
+ value: function getSubLayerDimensionAttribute(key, nullValue) {
439
+ var _this4 = this;
440
+
441
+ return function (cell) {
442
+ var _this4$state$dimensio = _this4.state.dimensions[key],
443
+ sortedBins = _this4$state$dimensio.sortedBins,
444
+ scaleFunc = _this4$state$dimensio.scaleFunc;
445
+ var bin = sortedBins.binMap[cell.index];
446
+
447
+ if (bin && bin.counts === 0) {
448
+ return nullValue;
449
+ }
416
450
 
417
- this.setDimensionState(key, {
418
- scaleFunc
419
- });
420
- }
421
-
422
- getSubLayerDimensionAttribute(key, nullValue) {
423
- return cell => {
424
- const {
425
- sortedBins,
426
- scaleFunc
427
- } = this.state.dimensions[key];
428
- const bin = sortedBins.binMap[cell.index];
429
-
430
- if (bin && bin.counts === 0) {
431
- return nullValue;
451
+ var cv = bin && bin.value;
452
+ var domain = scaleFunc.domain();
453
+ var isValueInDomain = cv >= domain[0] && cv <= domain[domain.length - 1];
454
+ return isValueInDomain ? scaleFunc(cv) : nullValue;
455
+ };
456
+ }
457
+ }, {
458
+ key: "getSubLayerAccessors",
459
+ value: function getSubLayerAccessors(props) {
460
+ var accessors = {};
461
+
462
+ for (var key in this.dimensionUpdaters) {
463
+ var accessor = this.dimensionUpdaters[key].accessor;
464
+ accessors[accessor] = this.getSubLayerDimensionAttribute(props, key);
432
465
  }
433
466
 
434
- const cv = bin && bin.value;
435
- const domain = scaleFunc.domain();
436
- const isValueInDomain = cv >= domain[0] && cv <= domain[domain.length - 1];
437
- return isValueInDomain ? scaleFunc(cv) : nullValue;
438
- };
439
- }
440
-
441
- getSubLayerAccessors(props) {
442
- const accessors = {};
443
-
444
- for (const key in this.dimensionUpdaters) {
445
- const {
446
- accessor
447
- } = this.dimensionUpdaters[key];
448
- accessors[accessor] = this.getSubLayerDimensionAttribute(props, key);
467
+ return accessors;
449
468
  }
469
+ }, {
470
+ key: "getPickingInfo",
471
+ value: function getPickingInfo(_ref3) {
472
+ var info = _ref3.info;
473
+ var isPicked = info.picked && info.index > -1;
474
+ var object = null;
475
+
476
+ if (isPicked) {
477
+ var cell = this.state.layerData.data[info.index];
478
+ var binInfo = {};
479
+
480
+ for (var key in this.dimensionUpdaters) {
481
+ var pickingInfo = this.dimensionUpdaters[key].pickingInfo;
482
+ var sortedBins = this.state.dimensions[key].sortedBins;
483
+ var value = sortedBins.binMap[cell.index] && sortedBins.binMap[cell.index].value;
484
+ binInfo[pickingInfo] = value;
485
+ }
450
486
 
451
- return accessors;
452
- }
453
-
454
- getPickingInfo({
455
- info
456
- }) {
457
- const isPicked = info.picked && info.index > -1;
458
- let object = null;
459
-
460
- if (isPicked) {
461
- const cell = this.state.layerData.data[info.index];
462
- const binInfo = {};
463
-
464
- for (const key in this.dimensionUpdaters) {
465
- const {
466
- pickingInfo
467
- } = this.dimensionUpdaters[key];
468
- const {
469
- sortedBins
470
- } = this.state.dimensions[key];
471
- const value = sortedBins.binMap[cell.index] && sortedBins.binMap[cell.index].value;
472
- binInfo[pickingInfo] = value;
487
+ object = Object.assign(binInfo, cell, {
488
+ points: cell.filteredPoints || cell.points
489
+ });
473
490
  }
474
491
 
475
- object = Object.assign(binInfo, cell, {
476
- points: cell.filteredPoints || cell.points
477
- });
492
+ info.picked = Boolean(object);
493
+ info.object = object;
494
+ return info;
478
495
  }
496
+ }, {
497
+ key: "getAccessor",
498
+ value: function getAccessor(dimensionKey) {
499
+ if (!this.dimensionUpdaters.hasOwnProperty(dimensionKey)) {
500
+ return nop;
501
+ }
479
502
 
480
- info.picked = Boolean(object);
481
- info.object = object;
482
- return info;
483
- }
484
-
485
- getAccessor(dimensionKey) {
486
- if (!this.dimensionUpdaters.hasOwnProperty(dimensionKey)) {
487
- return nop;
503
+ return this.dimensionUpdaters[dimensionKey].attributeAccessor;
488
504
  }
489
-
490
- return this.dimensionUpdaters[dimensionKey].attributeAccessor;
491
- }
492
-
493
- }
505
+ }], [{
506
+ key: "defaultDimensions",
507
+ value: function defaultDimensions() {
508
+ return _defaultDimensions;
509
+ }
510
+ }]);
511
+ return CPUAggregator;
512
+ }();
494
513
 
495
514
  exports.default = CPUAggregator;
496
515
  //# sourceMappingURL=cpu-aggregator.js.map