@deck.gl/aggregation-layers 8.6.0 → 8.6.4

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 (58) hide show
  1. package/dist/es5/aggregation-layer.js +109 -163
  2. package/dist/es5/aggregation-layer.js.map +1 -1
  3. package/dist/es5/contour-layer/contour-layer.js +240 -260
  4. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  5. package/dist/es5/contour-layer/contour-utils.js +65 -86
  6. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  7. package/dist/es5/contour-layer/marching-squares-codes.js +181 -106
  8. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  9. package/dist/es5/contour-layer/marching-squares.js +56 -59
  10. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  11. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +85 -121
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  13. package/dist/es5/cpu-grid-layer/grid-aggregator.js +93 -119
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  15. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -167
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  17. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +319 -322
  18. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  19. package/dist/es5/grid-aggregation-layer.js +202 -230
  20. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  21. package/dist/es5/grid-layer/grid-layer.js +61 -91
  22. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  23. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +24 -59
  24. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  25. package/dist/es5/heatmap-layer/heatmap-layer.js +515 -533
  26. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  27. package/dist/es5/heatmap-layer/triangle-layer.js +64 -91
  28. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  29. package/dist/es5/hexagon-layer/hexagon-aggregator.js +59 -77
  30. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  31. package/dist/es5/hexagon-layer/hexagon-layer.js +121 -164
  32. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  33. package/dist/es5/index.js +12 -12
  34. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +168 -193
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  36. package/dist/es5/screen-grid-layer/screen-grid-layer.js +235 -250
  37. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  38. package/dist/es5/utils/aggregation-operation-utils.js +16 -31
  39. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  40. package/dist/es5/utils/bin-sorter.js +118 -198
  41. package/dist/es5/utils/bin-sorter.js.map +1 -1
  42. package/dist/es5/utils/color-utils.js +8 -10
  43. package/dist/es5/utils/color-utils.js.map +1 -1
  44. package/dist/es5/utils/cpu-aggregator.js +323 -342
  45. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  46. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +20 -18
  47. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  48. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +545 -545
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  50. package/dist/es5/utils/grid-aggregation-utils.js +50 -44
  51. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  52. package/dist/es5/utils/prop-utils.js +2 -2
  53. package/dist/es5/utils/prop-utils.js.map +1 -1
  54. package/dist/es5/utils/resource-utils.js +32 -39
  55. package/dist/es5/utils/resource-utils.js.map +1 -1
  56. package/dist/es5/utils/scale-utils.js +36 -66
  57. package/dist/es5/utils/scale-utils.js.map +1 -1
  58. package/package.json +2 -2
@@ -7,28 +7,16 @@ 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
-
18
10
  var _binSorter = _interopRequireDefault(require("./bin-sorter"));
19
11
 
20
12
  var _scaleUtils = require("./scale-utils");
21
13
 
22
14
  var _aggregationOperationUtils = require("./aggregation-operation-utils");
23
15
 
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
-
28
16
  function nop() {}
29
17
 
30
- var dimensionSteps = ['getBins', 'getDomain', 'getScaleFunc'];
31
- var _defaultDimensions = [{
18
+ const dimensionSteps = ['getBins', 'getDomain', 'getScaleFunc'];
19
+ const defaultDimensions = [{
32
20
  key: 'fillColor',
33
21
  accessor: 'getFillColor',
34
22
  pickingInfo: 'colorValue',
@@ -130,13 +118,10 @@ var _defaultDimensions = [{
130
118
  nullValue: -1
131
119
  }];
132
120
 
133
- var defaultGetCellSize = function defaultGetCellSize(props) {
134
- return props.cellSize;
135
- };
121
+ const defaultGetCellSize = props => props.cellSize;
136
122
 
137
- var CPUAggregator = function () {
138
- function CPUAggregator(opts) {
139
- (0, _classCallCheck2.default)(this, CPUAggregator);
123
+ class CPUAggregator {
124
+ constructor(opts) {
140
125
  this.state = {
141
126
  layerData: {},
142
127
  dimensions: {}
@@ -146,370 +131,366 @@ var CPUAggregator = function () {
146
131
  this._getCellSize = opts.getCellSize || defaultGetCellSize;
147
132
  this._getAggregator = opts.getAggregator;
148
133
 
149
- this._addDimension(opts.dimensions || _defaultDimensions);
134
+ this._addDimension(opts.dimensions || defaultDimensions);
150
135
  }
151
136
 
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
- }
137
+ static defaultDimensions() {
138
+ return defaultDimensions;
139
+ }
172
140
 
173
- this.setState({
174
- aggregationDirty: aggregationDirty
175
- });
176
- return this.state;
177
- }
178
- }, {
179
- key: "setState",
180
- value: function setState(updateObject) {
181
- this.state = _objectSpread(_objectSpread({}, this.state), updateObject);
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;
182
158
  }
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);
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
+ }
203
178
  }
179
+ });
180
+ }
204
181
 
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
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
218
192
  };
219
- this.getSortedBins(props);
220
193
  }
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
- }
243
194
 
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) {
244
222
  if (getValue) {
245
- this.setDimensionState(key, {
246
- getValue: 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
247
229
  });
248
230
  }
249
231
  }
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
- }
311
232
 
312
- return oldProps[item.prop] !== props[item.prop];
313
- });
233
+ if (getValue) {
234
+ this.setDimensionState(key, {
235
+ getValue
236
+ });
237
+ }
314
238
  }
315
- }, {
316
- key: "getDimensionChanges",
317
- value: function getDimensionChanges(oldProps, props, changeFlags) {
318
- var _this2 = this;
239
+ }
319
240
 
320
- var updaters = [];
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
+ }
321
244
 
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
- });
245
+ addDimension(dimensions) {
246
+ this._addDimension(dimensions);
247
+ }
326
248
 
327
- if (needUpdate) {
328
- updaters.push(_this2.dimensionUpdaters[key][needUpdate].updater.bind(_this2, props, _this2.dimensionUpdaters[key]));
329
- }
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
330
260
  };
261
+ });
262
+ }
331
263
 
332
- for (var key in this.dimensionUpdaters) {
333
- _loop(key);
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]);
334
297
  }
335
298
 
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
- };
299
+ return oldProps[item.prop] !== props[item.prop];
300
+ });
301
+ }
369
302
 
370
- for (var key in this.dimensionUpdaters) {
371
- _loop2(key);
372
- }
303
+ getDimensionChanges(oldProps, props, changeFlags) {
304
+ const updaters = [];
373
305
 
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]);
306
+ for (const key in this.dimensionUpdaters) {
307
+ const needUpdate = dimensionSteps.find(step => this.needUpdateDimensionStep(this.dimensionUpdaters[key][step], oldProps, props, changeFlags));
308
+
309
+ if (needUpdate) {
310
+ updaters.push(this.dimensionUpdaters[key][needUpdate].updater.bind(this, props, this.dimensionUpdaters[key]));
381
311
  }
382
312
  }
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
391
- });
392
- this.setDimensionState(key, {
393
- sortedBins: sortedBins
394
- });
395
- this.getDimensionValueDomain(props, dimensionUpdater);
396
- }
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);
411
- }
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());
430
- }
431
313
 
432
- this.setDimensionState(key, {
433
- scaleFunc: scaleFunc
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
+ });
434
344
  });
435
345
  }
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
- }
450
346
 
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
- };
347
+ return updateTriggers;
348
+ }
349
+
350
+ getSortedBins(props) {
351
+ for (const key in this.dimensionUpdaters) {
352
+ this.getDimensionSortedBins(props, this.dimensionUpdaters[key]);
456
353
  }
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);
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
465
383
  }
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
+ }
466
391
 
467
- return accessors;
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());
468
415
  }
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
- }
486
416
 
487
- object = Object.assign(binInfo, cell, {
488
- points: cell.filteredPoints || cell.points
489
- });
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;
490
432
  }
491
433
 
492
- info.picked = Boolean(object);
493
- info.object = object;
494
- return info;
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);
495
449
  }
496
- }, {
497
- key: "getAccessor",
498
- value: function getAccessor(dimensionKey) {
499
- if (!this.dimensionUpdaters.hasOwnProperty(dimensionKey)) {
500
- return nop;
450
+
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;
501
473
  }
502
474
 
503
- return this.dimensionUpdaters[dimensionKey].attributeAccessor;
475
+ object = Object.assign(binInfo, cell, {
476
+ points: cell.filteredPoints || cell.points
477
+ });
504
478
  }
505
- }], [{
506
- key: "defaultDimensions",
507
- value: function defaultDimensions() {
508
- return _defaultDimensions;
479
+
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;
509
488
  }
510
- }]);
511
- return CPUAggregator;
512
- }();
489
+
490
+ return this.dimensionUpdaters[dimensionKey].attributeAccessor;
491
+ }
492
+
493
+ }
513
494
 
514
495
  exports.default = CPUAggregator;
515
496
  //# sourceMappingURL=cpu-aggregator.js.map