Error when dispatching addDataToMap to update dataset with the same id
- Dominant language
- TypeScript
- Stars
- 12k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 66
Description
**Describe the bug**
If addDataToMap is dispatched a second time with the same dataset.info.id, visualization is not updated and error printed in console.
```
caught TypeError: Cannot read properties of undefined (reading '7')
at RowDataContainer.valueAt (row-data-container.js:71:32)
at maybeToDate (data-utils.js:137:13)
at indexValueAccessor (kepler-table.js:321:37)
at Array.map ()
at getQuantileDomain (data-scale-utils.js:29:61)
at KeplerTable.getColumnLayerDomain (kepler-table.js:332:33)
at PointLayer.calculateLayerDomain (base-layer.js:1039:20)
at base-layer.js:930:36
at Array.forEach ()
at PointLayer.updateLayerDomain (base-layer.js:923:40)
```
**To Reproduce**
I created demo to reproduce issue based in kepler example https://github.com/dekart-xyz/kepler.gl/blob/reproduce-update-bug/examples/update-dataset/src/app.js
```
{
props.dispatch(addDataToMap({
datasets: sampleData1
}))
}}>Step 1: Add Data
{
props.dispatch(addDataToMap({
datasets: sampleData2
}))
}}>Step 2: Update data
```
You can check out and run demo to reproduce error
**Expected behavior**
Visualization updated without errors when dataset with the same ID added to the map
**Screenshots**

**Desktop (please complete the following information):**
- OS: macOS
- Browser: Google Chrome
- Version 112.0.5615.137 (Official Build) (arm64)
**Additional context**
The error was first noticed by users of [dekart.xyz](http://dekart.xyz) and raised in the issue https://github.com/dekart-xyz/dekart/issues/93 ; the workaround is to remove dataset and add it again, see implementation example: https://github.com/dekart-xyz/dekart/commit/62c3f2c3f0814a09476413cbf95efa238da4aa4c#diff-5fa4759d43b71842834b06794432470ae99d15cb3edab35575c49ca33915107aR81
I took a fair attempt to debug and fix issue https://github.com/dekart-xyz/kepler.gl/commit/98efff98189edd1a4ff67349e3daf2b13e942e84#diff-0d85c15743ec491b2f6aab7368f1d90c81ffbcbeb5a9689de19bdad6da3fe7deR1040
I was able to fix `calculateLayerDomain` but more errors occur, including `deck.gl` errors.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with examples/update-dataset/src/app.js and reproduce the second addDataToMap dispatch using the linked sample data. Trace the stack from RowDataContainer.valueAt through calculateLayerDomain and the related kepler-table paths, noting the attempted calculateLayerDomain fix. Done means replacing a dataset with the same ID updates the visualization without console or deck.gl errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100