@vitessce/scatterplot 2.0.3-beta.0 → 3.0.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.
Files changed (73) hide show
  1. package/dist/deflate-24a61b7a.js +13 -0
  2. package/dist/index-d78d4568.js +142036 -0
  3. package/dist/index.js +15 -5
  4. package/dist/jpeg-19791032.js +840 -0
  5. package/dist/lerc-867fd2ef.js +2014 -0
  6. package/dist/lzw-40577136.js +128 -0
  7. package/dist/packbits-eab43a40.js +30 -0
  8. package/dist/pako.esm-68f84e2a.js +4022 -0
  9. package/dist/raw-66364181.js +12 -0
  10. package/dist/webimage-0fe27785.js +32 -0
  11. package/dist-tsc/EmptyMessage.d.ts +2 -0
  12. package/dist-tsc/EmptyMessage.d.ts.map +1 -0
  13. package/dist-tsc/Scatterplot.d.ts +10 -0
  14. package/dist-tsc/Scatterplot.d.ts.map +1 -0
  15. package/{dist → dist-tsc}/Scatterplot.js +12 -2
  16. package/dist-tsc/ScatterplotOptions.d.ts +2 -0
  17. package/dist-tsc/ScatterplotOptions.d.ts.map +1 -0
  18. package/{dist → dist-tsc}/ScatterplotOptions.js +13 -7
  19. package/dist-tsc/ScatterplotTooltipSubscriber.d.ts +2 -0
  20. package/dist-tsc/ScatterplotTooltipSubscriber.d.ts.map +1 -0
  21. package/dist-tsc/index.d.ts +6 -0
  22. package/dist-tsc/index.d.ts.map +1 -0
  23. package/dist-tsc/index.js +5 -0
  24. package/dist-tsc/shared-spatial-scatterplot/AbstractSpatialOrScatterplot.d.ts +82 -0
  25. package/dist-tsc/shared-spatial-scatterplot/AbstractSpatialOrScatterplot.d.ts.map +1 -0
  26. package/{dist → dist-tsc}/shared-spatial-scatterplot/AbstractSpatialOrScatterplot.js +9 -4
  27. package/dist-tsc/shared-spatial-scatterplot/ToolMenu.d.ts +4 -0
  28. package/dist-tsc/shared-spatial-scatterplot/ToolMenu.d.ts.map +1 -0
  29. package/{dist → dist-tsc}/shared-spatial-scatterplot/ToolMenu.js +32 -7
  30. package/dist-tsc/shared-spatial-scatterplot/ToolMenu.test.d.ts +2 -0
  31. package/dist-tsc/shared-spatial-scatterplot/ToolMenu.test.d.ts.map +1 -0
  32. package/dist-tsc/shared-spatial-scatterplot/ToolMenu.test.js +23 -0
  33. package/dist-tsc/shared-spatial-scatterplot/cursor.d.ts +4 -0
  34. package/dist-tsc/shared-spatial-scatterplot/cursor.d.ts.map +1 -0
  35. package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.d.ts +3 -0
  36. package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.d.ts.map +1 -0
  37. package/{dist → dist-tsc}/shared-spatial-scatterplot/dynamic-opacity.js +1 -1
  38. package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.test.d.ts +2 -0
  39. package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.test.d.ts.map +1 -0
  40. package/{dist → dist-tsc}/shared-spatial-scatterplot/dynamic-opacity.test.js +1 -1
  41. package/dist-tsc/shared-spatial-scatterplot/force-collide-rects.d.ts +13 -0
  42. package/dist-tsc/shared-spatial-scatterplot/force-collide-rects.d.ts.map +1 -0
  43. package/dist-tsc/shared-spatial-scatterplot/force-collide-rects.test.d.ts +2 -0
  44. package/dist-tsc/shared-spatial-scatterplot/force-collide-rects.test.d.ts.map +1 -0
  45. package/{dist → dist-tsc}/shared-spatial-scatterplot/force-collide-rects.test.js +1 -1
  46. package/dist-tsc/shared-spatial-scatterplot/index.d.ts +6 -0
  47. package/dist-tsc/shared-spatial-scatterplot/index.d.ts.map +1 -0
  48. package/dist-tsc/shared-spatial-scatterplot/index.js +5 -0
  49. package/dist-tsc/shared-spatial-scatterplot/quadtree.d.ts +10 -0
  50. package/dist-tsc/shared-spatial-scatterplot/quadtree.d.ts.map +1 -0
  51. package/{dist → dist-tsc}/shared-spatial-scatterplot/quadtree.js +1 -1
  52. package/package.json +25 -13
  53. package/src/EmptyMessage.js +11 -0
  54. package/src/Scatterplot.js +396 -0
  55. package/src/ScatterplotOptions.js +269 -0
  56. package/src/ScatterplotTooltipSubscriber.js +38 -0
  57. package/src/index.js +11 -0
  58. package/src/shared-spatial-scatterplot/AbstractSpatialOrScatterplot.js +280 -0
  59. package/src/shared-spatial-scatterplot/ToolMenu.js +143 -0
  60. package/src/shared-spatial-scatterplot/ToolMenu.test.jsx +26 -0
  61. package/src/shared-spatial-scatterplot/cursor.js +23 -0
  62. package/src/shared-spatial-scatterplot/dynamic-opacity.js +58 -0
  63. package/src/shared-spatial-scatterplot/dynamic-opacity.test.js +33 -0
  64. package/src/shared-spatial-scatterplot/force-collide-rects.js +189 -0
  65. package/src/shared-spatial-scatterplot/force-collide-rects.test.js +72 -0
  66. package/src/shared-spatial-scatterplot/index.js +8 -0
  67. package/src/shared-spatial-scatterplot/quadtree.js +27 -0
  68. package/dist/shared-spatial-scatterplot/ToolMenu.test.js +0 -16
  69. package/dist/shared-spatial-scatterplot/index.js +0 -5
  70. /package/{dist → dist-tsc}/EmptyMessage.js +0 -0
  71. /package/{dist → dist-tsc}/ScatterplotTooltipSubscriber.js +0 -0
  72. /package/{dist → dist-tsc}/shared-spatial-scatterplot/cursor.js +0 -0
  73. /package/{dist → dist-tsc}/shared-spatial-scatterplot/force-collide-rects.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/scatterplot",
3
- "version": "2.0.3-beta.0",
3
+ "version": "3.0.0",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -8,34 +8,46 @@
8
8
  "url": "git+https://github.com/vitessce/vitessce.git"
9
9
  },
10
10
  "license": "MIT",
11
+ "type": "module",
11
12
  "main": "dist/index.js",
12
13
  "files": [
13
- "dist"
14
+ "src",
15
+ "dist",
16
+ "dist-tsc"
14
17
  ],
15
18
  "dependencies": {
16
19
  "@material-ui/core": "~4.12.3",
20
+ "@material-ui/icons": "~4.11.2",
17
21
  "clsx": "^1.1.1",
18
22
  "d3-force": "^2.1.1",
19
23
  "d3-quadtree": "^1.0.7",
20
- "lodash": "^4.17.21",
21
- "@vitessce/constants-internal": "2.0.3-beta.0",
22
- "@vitessce/icons": "2.0.3-beta.0",
23
- "@vitessce/gl": "2.0.3-beta.0",
24
- "@vitessce/utils": "2.0.3-beta.0",
25
- "@vitessce/tooltip": "2.0.3-beta.0",
26
- "@vitessce/vit-s": "2.0.3-beta.0"
24
+ "lodash-es": "^4.17.21",
25
+ "@vitessce/constants-internal": "3.0.0",
26
+ "@vitessce/gl": "3.0.0",
27
+ "@vitessce/icons": "3.0.0",
28
+ "@vitessce/tooltip": "3.0.0",
29
+ "@vitessce/utils": "3.0.0",
30
+ "@vitessce/vit-s": "3.0.0"
27
31
  },
28
32
  "devDependencies": {
29
33
  "react": "^18.0.0",
30
- "vite": "^3.0.0",
31
- "vitest": "^0.23.4"
34
+ "vite": "^4.3.0",
35
+ "vitest": "^0.23.4",
36
+ "@testing-library/jest-dom": "^5.16.4",
37
+ "@testing-library/react": "^13.3.0"
32
38
  },
33
39
  "peerDependencies": {
34
40
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
35
41
  },
36
42
  "scripts": {
37
- "start": "tsc --watch",
38
- "build": "tsc",
43
+ "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
39
44
  "test": "pnpm exec vitest --run -r ../../../ --dir ."
45
+ },
46
+ "module": "dist/index.js",
47
+ "exports": {
48
+ ".": {
49
+ "types": "./dist-tsc/index.d.ts",
50
+ "import": "./dist/index.js"
51
+ }
40
52
  }
41
53
  }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+
3
+ export default function EmptyMessage(props) {
4
+ const {
5
+ visible,
6
+ message,
7
+ } = props;
8
+ return visible ? (
9
+ <div>{message}</div>
10
+ ) : null;
11
+ }
@@ -0,0 +1,396 @@
1
+ /* eslint-disable no-param-reassign */
2
+ import React, { forwardRef } from 'react';
3
+ import { forceSimulation } from 'd3-force';
4
+ import {
5
+ deck, getSelectionLayers, ScaledExpressionExtension, SelectionExtension,
6
+ } from '@vitessce/gl';
7
+ import { getDefaultColor } from '@vitessce/utils';
8
+ import {
9
+ AbstractSpatialOrScatterplot, createQuadTree, forceCollideRects, getOnHoverCallback,
10
+ } from './shared-spatial-scatterplot/index.js';
11
+
12
+ const CELLS_LAYER_ID = 'scatterplot';
13
+ const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
14
+ const NUM_FORCE_SIMULATION_TICKS = 100;
15
+ const LABEL_UPDATE_ZOOM_DELTA = 0.25;
16
+
17
+ // Default getter function props.
18
+ const makeDefaultGetCellColors = (cellColors, obsIndex, theme) => (object, { index }) => {
19
+ const [r, g, b, a] = (cellColors && obsIndex && cellColors.get(obsIndex[index]))
20
+ || getDefaultColor(theme);
21
+ return [r, g, b, 255 * (a || 1)];
22
+ };
23
+ const makeDefaultGetObsCoords = obsEmbedding => i => ([
24
+ obsEmbedding.data[0][i],
25
+ obsEmbedding.data[1][i],
26
+ 0,
27
+ ]);
28
+ const makeFlippedGetObsCoords = obsEmbedding => i => ([
29
+ obsEmbedding.data[0][i],
30
+ -obsEmbedding.data[1][i],
31
+ 0,
32
+ ]);
33
+ const getPosition = (object, { index, data, target }) => {
34
+ target[0] = data.src.obsEmbedding.data[0][index];
35
+ target[1] = -data.src.obsEmbedding.data[1][index];
36
+ target[2] = 0;
37
+ return target;
38
+ };
39
+
40
+ /**
41
+ * React component which renders a scatterplot from cell data.
42
+ * @param {object} props
43
+ * @param {string} props.uuid A unique identifier for this component.
44
+ * @param {string} props.theme The current vitessce theme.
45
+ * @param {object} props.viewState The deck.gl view state.
46
+ * @param {function} props.setViewState Function to call to update the deck.gl view state.
47
+ * @param {object} props.cells
48
+ * @param {string} props.mapping The name of the coordinate mapping field,
49
+ * for each cell, for example "PCA" or "t-SNE".
50
+ * @param {Map} props.cellColors Mapping of cell IDs to colors.
51
+ * @param {array} props.cellSelection Array of selected cell IDs.
52
+ * @param {array} props.cellFilter Array of filtered cell IDs. By default, null.
53
+ * @param {number} props.cellRadius The value for `radiusScale` to pass
54
+ * to the deck.gl cells ScatterplotLayer.
55
+ * @param {number} props.cellOpacity The value for `opacity` to pass
56
+ * to the deck.gl cells ScatterplotLayer.
57
+ * @param {function} props.getCellCoords Getter function for cell coordinates
58
+ * (used by the selection layer).
59
+ * @param {function} props.getCellPosition Getter function for cell [x, y, z] position.
60
+ * @param {function} props.getCellColor Getter function for cell color as [r, g, b] array.
61
+ * @param {function} props.getExpressionValue Getter function for cell expression value.
62
+ * @param {function} props.getCellIsSelected Getter function for cell layer isSelected.
63
+ * @param {function} props.setCellSelection
64
+ * @param {function} props.setCellHighlight
65
+ * @param {function} props.updateViewInfo
66
+ * @param {function} props.onToolChange Callback for tool changes
67
+ * (lasso/pan selection tools).
68
+ * @param {function} props.onCellClick Getter function for cell layer onClick.
69
+ * @param {object} props.originalViewState A viewState object to pass to
70
+ * setViewState upon clicking the recenter button.
71
+ */
72
+ class Scatterplot extends AbstractSpatialOrScatterplot {
73
+ constructor(props) {
74
+ super(props);
75
+
76
+ // To avoid storing large arrays/objects
77
+ // in React state, this component
78
+ // uses instance variables.
79
+ // All instance variables used in this class:
80
+ this.cellsQuadTree = null;
81
+ this.cellsLayer = null;
82
+ this.cellsData = null;
83
+ this.cellSetsForceSimulation = forceCollideRects();
84
+ this.cellSetsLabelPrevZoom = null;
85
+ this.cellSetsLayers = [];
86
+
87
+ // Initialize data and layers.
88
+ this.onUpdateCellsData();
89
+ this.onUpdateCellsLayer();
90
+ this.onUpdateCellSetsLayers();
91
+ }
92
+
93
+ createCellsLayer() {
94
+ const {
95
+ obsEmbeddingIndex: obsIndex,
96
+ theme,
97
+ cellRadius = 1.0,
98
+ cellOpacity = 1.0,
99
+ // cellFilter,
100
+ cellSelection,
101
+ setCellHighlight,
102
+ setComponentHover,
103
+ getCellIsSelected,
104
+ cellColors,
105
+ getCellColor = makeDefaultGetCellColors(cellColors, obsIndex, theme),
106
+ getExpressionValue,
107
+ onCellClick,
108
+ geneExpressionColormap,
109
+ geneExpressionColormapRange = [0.0, 1.0],
110
+ cellColorEncoding,
111
+ } = this.props;
112
+ return new deck.ScatterplotLayer({
113
+ id: CELLS_LAYER_ID,
114
+ // Note that the reference for the object passed to the data prop should not change,
115
+ // otherwise DeckGL will need to do a full re-render every time .createCellsLayer is called,
116
+ // which can be very often to handle cellOpacity and cellRadius updates for dynamic opacity.
117
+ data: this.cellsData,
118
+ coordinateSystem: deck.COORDINATE_SYSTEM.CARTESIAN,
119
+ visible: true,
120
+ pickable: true,
121
+ autoHighlight: true,
122
+ filled: true,
123
+ stroked: true,
124
+ backgroundColor: (theme === 'dark' ? [0, 0, 0] : [241, 241, 241]),
125
+ getCellIsSelected,
126
+ opacity: cellOpacity,
127
+ radiusScale: cellRadius,
128
+ radiusMinPixels: 1,
129
+ radiusMaxPixels: 30,
130
+ // Our radius pixel setters measure in pixels.
131
+ radiusUnits: 'pixels',
132
+ lineWidthUnits: 'pixels',
133
+ getPosition,
134
+ getFillColor: getCellColor,
135
+ getLineColor: getCellColor,
136
+ getRadius: 1,
137
+ getExpressionValue,
138
+ getLineWidth: 0,
139
+ extensions: [
140
+ new ScaledExpressionExtension(),
141
+ new SelectionExtension({ instanced: true }),
142
+ ],
143
+ colorScaleLo: geneExpressionColormapRange[0],
144
+ colorScaleHi: geneExpressionColormapRange[1],
145
+ isExpressionMode: (cellColorEncoding === 'geneSelection'),
146
+ colormap: geneExpressionColormap,
147
+ onClick: (info) => {
148
+ if (onCellClick) {
149
+ onCellClick(info);
150
+ }
151
+ },
152
+ onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
153
+ updateTriggers: {
154
+ getExpressionValue,
155
+ getFillColor: [cellColorEncoding, cellSelection, cellColors],
156
+ getLineColor: [cellColorEncoding, cellSelection, cellColors],
157
+ getCellIsSelected,
158
+ },
159
+ });
160
+ }
161
+
162
+ createCellSetsLayers() {
163
+ const {
164
+ theme,
165
+ cellSetPolygons,
166
+ viewState,
167
+ cellSetPolygonsVisible,
168
+ cellSetLabelsVisible,
169
+ cellSetLabelSize,
170
+ } = this.props;
171
+
172
+ const result = [];
173
+
174
+ if (cellSetPolygonsVisible) {
175
+ result.push(new deck.PolygonLayer({
176
+ id: 'cell-sets-polygon-layer',
177
+ data: cellSetPolygons,
178
+ stroked: true,
179
+ filled: false,
180
+ wireframe: true,
181
+ lineWidthMaxPixels: 1,
182
+ getPolygon: d => d.hull,
183
+ getLineColor: d => d.color,
184
+ getLineWidth: 1,
185
+ }));
186
+ }
187
+
188
+ if (cellSetLabelsVisible) {
189
+ const { zoom } = viewState;
190
+ const nodes = cellSetPolygons.map(p => ({
191
+ x: p.centroid[0],
192
+ y: p.centroid[1],
193
+ label: p.name,
194
+ }));
195
+
196
+ const collisionForce = this.cellSetsForceSimulation
197
+ .size(d => ([
198
+ cellSetLabelSize * 1 / (2 ** zoom) * 4 * d.label.length,
199
+ cellSetLabelSize * 1 / (2 ** zoom) * 1.5,
200
+ ]));
201
+
202
+ forceSimulation()
203
+ .nodes(nodes)
204
+ .force('collision', collisionForce)
205
+ .tick(NUM_FORCE_SIMULATION_TICKS);
206
+
207
+ result.push(new deck.TextLayer({
208
+ id: 'cell-sets-text-layer',
209
+ data: nodes,
210
+ getPosition: d => ([d.x, d.y]),
211
+ getText: d => d.label,
212
+ getColor: (theme === 'dark' ? [255, 255, 255] : [0, 0, 0]),
213
+ getSize: cellSetLabelSize,
214
+ getAngle: 0,
215
+ getTextAnchor: 'middle',
216
+ getAlignmentBaseline: 'center',
217
+ fontFamily: LABEL_FONT_FAMILY,
218
+ fontWeight: 'normal',
219
+ }));
220
+ }
221
+
222
+ return result;
223
+ }
224
+
225
+ createSelectionLayers() {
226
+ const {
227
+ obsEmbeddingIndex: obsIndex,
228
+ obsEmbedding,
229
+ viewState,
230
+ setCellSelection,
231
+ } = this.props;
232
+ const { tool } = this.state;
233
+ const { cellsQuadTree } = this;
234
+ const flipYTooltip = true;
235
+ const getCellCoords = makeDefaultGetObsCoords(obsEmbedding);
236
+ return getSelectionLayers(
237
+ tool,
238
+ viewState.zoom,
239
+ CELLS_LAYER_ID,
240
+ getCellCoords,
241
+ obsIndex,
242
+ setCellSelection,
243
+ cellsQuadTree,
244
+ flipYTooltip,
245
+ );
246
+ }
247
+
248
+ getLayers() {
249
+ const {
250
+ cellsLayer,
251
+ cellSetsLayers,
252
+ } = this;
253
+ return [
254
+ cellsLayer,
255
+ ...cellSetsLayers,
256
+ ...this.createSelectionLayers(),
257
+ ];
258
+ }
259
+
260
+ onUpdateCellsData() {
261
+ const { obsEmbedding } = this.props;
262
+ if (obsEmbedding) {
263
+ const getCellCoords = makeDefaultGetObsCoords(obsEmbedding);
264
+ this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
265
+ this.cellsData = {
266
+ src: {
267
+ obsEmbedding,
268
+ },
269
+ length: obsEmbedding.shape[1],
270
+ };
271
+ }
272
+ }
273
+
274
+ onUpdateCellsLayer() {
275
+ const { obsEmbeddingIndex, obsEmbedding } = this.props;
276
+ if (obsEmbeddingIndex && obsEmbedding) {
277
+ this.cellsLayer = this.createCellsLayer();
278
+ } else {
279
+ this.cellsLayer = null;
280
+ }
281
+ }
282
+
283
+ onUpdateCellSetsLayers(onlyViewStateChange) {
284
+ // Because the label sizes for the force simulation depend on the zoom level,
285
+ // we _could_ run the simulation every time the zoom level changes.
286
+ // However, this has a performance impact in firefox.
287
+ if (onlyViewStateChange) {
288
+ const { viewState, cellSetLabelsVisible } = this.props;
289
+ const { zoom } = viewState;
290
+ const { cellSetsLabelPrevZoom } = this;
291
+ // Instead, we can just check if the zoom level has changed
292
+ // by some relatively large delta, to be more conservative
293
+ // about re-running the force simulation.
294
+ if (cellSetLabelsVisible
295
+ && (
296
+ cellSetsLabelPrevZoom === null
297
+ || Math.abs(cellSetsLabelPrevZoom - zoom) > LABEL_UPDATE_ZOOM_DELTA
298
+ )
299
+ ) {
300
+ this.cellSetsLayers = this.createCellSetsLayers();
301
+ this.cellSetsLabelPrevZoom = zoom;
302
+ }
303
+ } else {
304
+ // Otherwise, something more substantial than just
305
+ // the viewState has changed, such as the label array
306
+ // itself, so we always want to update the layer
307
+ // in this case.
308
+ this.cellSetsLayers = this.createCellSetsLayers();
309
+ }
310
+ }
311
+
312
+ viewInfoDidUpdate() {
313
+ const {
314
+ obsEmbeddingIndex,
315
+ obsEmbedding,
316
+ } = this.props;
317
+ super.viewInfoDidUpdate(
318
+ obsEmbeddingIndex,
319
+ obsEmbedding,
320
+ makeFlippedGetObsCoords,
321
+ );
322
+ }
323
+
324
+ /**
325
+ * Here, asynchronously check whether props have
326
+ * updated which require re-computing memoized variables,
327
+ * followed by a re-render.
328
+ * This function does not follow React conventions or paradigms,
329
+ * it is only implemented this way to try to squeeze out
330
+ * performance.
331
+ * @param {object} prevProps The previous props to diff against.
332
+ */
333
+ componentDidUpdate(prevProps) {
334
+ this.viewInfoDidUpdate();
335
+
336
+ const shallowDiff = propName => (prevProps[propName] !== this.props[propName]);
337
+ let forceUpdate = false;
338
+ if (['obsEmbedding'].some(shallowDiff)) {
339
+ // Cells data changed.
340
+ this.onUpdateCellsData();
341
+ forceUpdate = true;
342
+ }
343
+
344
+ if ([
345
+ 'obsEmbeddingIndex', 'obsEmbedding', 'cellFilter', 'cellSelection', 'cellColors',
346
+ 'cellRadius', 'cellOpacity', 'cellRadiusMode', 'geneExpressionColormap',
347
+ 'geneExpressionColormapRange', 'geneSelection', 'cellColorEncoding',
348
+ 'getExpressionValue',
349
+ ].some(shallowDiff)) {
350
+ // Cells layer props changed.
351
+ this.onUpdateCellsLayer();
352
+ forceUpdate = true;
353
+ }
354
+ if ([
355
+ 'cellSetPolygons', 'cellSetPolygonsVisible',
356
+ 'cellSetLabelsVisible', 'cellSetLabelSize',
357
+ ].some(shallowDiff)) {
358
+ // Cell sets layer props changed.
359
+ this.onUpdateCellSetsLayers(false);
360
+ forceUpdate = true;
361
+ }
362
+ if (shallowDiff('viewState')) {
363
+ // The viewState prop has changed (due to zoom or pan).
364
+ this.onUpdateCellSetsLayers(true);
365
+ forceUpdate = true;
366
+ }
367
+ if (forceUpdate) {
368
+ this.forceUpdate();
369
+ }
370
+ }
371
+
372
+ recenter() {
373
+ const { originalViewState, setViewState } = this.props;
374
+ if (Array.isArray(originalViewState?.target) && typeof originalViewState?.zoom === 'number') {
375
+ setViewState(originalViewState);
376
+ }
377
+ }
378
+
379
+ // render() is implemented in the abstract parent class.
380
+ }
381
+
382
+ /**
383
+ * Need this wrapper function here,
384
+ * since we want to pass a forwardRef
385
+ * so that outer components can
386
+ * access the grandchild DeckGL ref,
387
+ * but we are using a class component.
388
+ */
389
+ const ScatterplotWrapper = forwardRef((props, deckRef) => (
390
+ <Scatterplot
391
+ {...props}
392
+ deckRef={deckRef}
393
+ />
394
+ ));
395
+ ScatterplotWrapper.displayName = 'ScatterplotWrapper';
396
+ export default ScatterplotWrapper;