openwisp / openwisp/netjsongraph.js

[bug] Update clustered map nodes in real time

Open
#580 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. Render a geographic map with clustering: true and at least two nearby Point nodes.
  2. Keep the map below disableClusteringAtLevel so that a cluster is visible.
  3. Call moveNodeInRealTime for a cluster child.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.