openwisp / openwisp/netjsongraph.js
[bug] Update clustered map nodes in real time
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 314
- Forks
- 119
- Avg merge
- 18h 17m
- Merged PRs (30d)
- 15
Description
Describe the bug
moveNodeInRealTime(id, location) assumes every ECharts scatter datum has a node property. Cluster data has childNodes instead, so this lookup throws:
series.data.findIndex((datum) => datum.node.id === id)
The method also supports only coordinate updates. Applications receiving full node updates cannot safely update labels or properties for visible markers and cluster children.
Steps To Reproduce
- Render a geographic map with
clustering: trueand at least two nearby Point nodes. - Keep the map below
disableClusteringAtLevelso that a cluster is visible. - Call
moveNodeInRealTimefor a cluster child. - Observe
TypeError: Cannot read properties of undefined (reading 'id').
Expected behavior
NetJSONGraph should provide a cluster-safe full-node update API, for example:
updateNodeInRealTime(id, {
location: {lng, lat},
label,
properties,
});
The API must update canonical node data and metadata for visible markers and cluster children. It must recalculate clusters only when coordinates change. For a coordinate update, it must correctly handle a node joining or leaving a cluster and update the cluster count, centroid, and status grouping.
moveNodeInRealTime(id, location) should remain available and delegate to the new API.
Screenshots
Not applicable.
System Informatioon:
- OS: production environment, not available
- Node.js Version: not available
- Browser and Browser Version: Chromium, version not available
Additional context
Resolve the node through nodeLinkIndex[id], not only the visible scatter series. Preserve _origLocation when updating coordinates because clustering uses it to restore source geometry. Extract the duplicated cluster-series generation used on initial render and zoomend, then batch incoming updates so one burst causes one redraw.
Add regression coverage for cluster entries preceding normal markers, coordinate changes across cluster boundaries, label-only updates, and batched updates.
Related Monitoring follow-up
We'll need to work on openwisp/openwisp-monitoring#833 to integrate the full Location WebSocket payload after this API is available.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with moveNodeInRealTime, nodeLinkIndex, and the visible scatter-series handling described in the issue; trace the duplicated cluster-series generation used during initial render and zoomend. Define completion as a cluster-safe full-node update that preserves _origLocation, updates visible markers and cluster children, recalculates only when coordinates change, and batches one redraw per burst. Add regression coverage for cluster ordering, cluster-boundary moves, label-only updates, and batched updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100