Skip to content

[fix] Fixed redundant node labels and overlays #454#474

Merged
nemesifier merged 18 commits intoopenwisp:masterfrom
Dhruv-ub:issues/454-fix-redundant-labels
Apr 22, 2026
Merged

[fix] Fixed redundant node labels and overlays #454#474
nemesifier merged 18 commits intoopenwisp:masterfrom
Dhruv-ub:issues/454-fix-redundant-labels

Conversation

@Dhruv-ub
Copy link
Copy Markdown
Contributor

@Dhruv-ub Dhruv-ub commented Dec 16, 2025

To improve the interaction between map labels and hover overlays to avoid visual clutter and interaction conflicts, especially at higher zoom levels.
The hover overlay is confirmed to be the default ECharts tooltip. Its behavior is made more predictable, while label rendering is adjusted so labels no longer interfere with hover interactions.

Fixes #454

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #454.

Description of Changes

  • Clarified and stabilized tooltip behavior (default ECharts tooltip, confined to viewport, no hide delay).
  • Introduced showMapLabelsAtZoom to explicitly control when geographic map labels are displayed.
  • Preserved backward compatibility with showLabelsAtZoomLevel.
  • Made both graph and map labels non-interactive (silent) to prevent overlap and hover conflicts.
  • Ensured labels remain a passive, non-invasive layer while tooltips remain the primary interactive overlay.
  • Aligned configuration naming between graph and map label zoom behavior.

Screenshot

IMG20251216200740

@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

Test.mp4

@Dhruv-ub Dhruv-ub changed the title [netjsongraph] Fix redundant node labels and overlays #454 [Fix] redundant node labels and overlays #454 Dec 16, 2025
@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

Fixed the no-shadow linting error in src/js/netjsongraph.render.js and finalized the parameter rename in src/js/netjsongraph.config.js.

Could you please run the checks again?

Copy link
Copy Markdown
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch contains changes to the formatting which are polluting the actual changes. If formatting needs to be updated let's open a PR to master with only formatting changes.

clusterSeparation: 20,
showMetaOnNarrowScreens: false,
showLabelsAtZoomLevel: 13,
showMapLabelsAtZoom: 13,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unsolicited backward incompatible renaming

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. I am working on the fixes now. I will revert showMapLabelsAtZoom back to showLabelsAtZoomLevel and remove the unrelated formatting changes. I will force push the updates shortly to clean up the commit history.

Copy link
Copy Markdown
Member

@nemesifier nemesifier Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was wrong about this comment, we need to read the issue description again more closely. I am sorry for this mistake, I have too many things on my mind right now and I can forget some details, let's follow the issue description and reply to the issues brought up there and use it as a guide to resolve the issue. That's the right way to do it.

@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch from 5648e36 to a4054d7 Compare December 22, 2025 19:46
@Dhruv-ub Dhruv-ub changed the title [Fix] redundant node labels and overlays #454 [Fix] Resolve redundant node labels and overlays #454 Dec 22, 2025
@Dhruv-ub Dhruv-ub requested a review from nemesifier December 22, 2025 20:54
@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch 5 times, most recently from c6c106d to 465e1e7 Compare December 26, 2025 16:28
@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

I'm working in a WSL (Ubuntu) environment and have run the Prettier formatters, but the QA checks are still failing locally on my machine.

I've tried to resolve the formatting/linting issues, but I'm stuck on why the checks persist in failing. Could you please check the logs and advise what might be missing?"

Copy link
Copy Markdown
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to insist, please only send the bugfix change, do not send any other change, if QA checks fail, we'll look into it. The PR in the current state contains a lot of other changes unrelated to the bugfix which is time consuming for maintaienrs to review.

@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch 5 times, most recently from a685e69 to 1f239ae Compare December 27, 2025 16:21
@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

Done please have a look on why ci build failing.

@nemesifier
Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 5, 2026

Warning

Rate limit exceeded

@nemesifier has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 41 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 42 minutes and 41 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f10cd7d4-b26b-45f1-b316-7afa3b51ba86

📥 Commits

Reviewing files that changed from the base of the PR and between 7f12a96 and 9014ffc.

📒 Files selected for processing (4)
  • README.md
  • src/js/netjsongraph.render.js
  • src/js/netjsongraph.util.js
  • test/netjsongraph.render.test.js

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change addresses label and overlay redundancy in geographic maps by renaming the configuration option showLabelsAtZoomLevel to showMapLabelsAtZoom for consistency, increasing its default threshold from 7 to 13, and enhancing label visibility to be fully zoom-driven and controllable (including complete disabling via false). The rendering logic is updated to apply a silent flag to labels and adjust visibility based on the zoom threshold. Tooltip hideDelay is set to 0, cluster zoom behavior is improved to zoom into a higher level on click, and backward compatibility is maintained through configuration aliasing in the constructor.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • nemesifier

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Bug Fixes ❌ Error The regression test properly fixes bug #454 but violates determinism by using hardcoded sleep delays instead of waiting for actual state changes, and contains unresolved dead code. Replace await driver.sleep(500) calls with driver.wait() conditions checking actual echarts state, and remove commented-out dead code on line 602.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required [fix] prefix and directly addresses the linked issue (#454) about redundant node labels and overlays, matching the core problem statement.
Description check ✅ Passed The description is comprehensive, following the template structure with completed checklist, issue reference, clear change description, and supporting screenshot demonstrating the fix.
Linked Issues check ✅ Passed The PR implementation fully addresses all coding requirements from issue #454: clarifies tooltip behavior, introduces showMapLabelsAtZoom, preserves backward compatibility, marks labels as non-interactive, and aligns naming conventions.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issue #454; modifications to tooltip configuration, label visibility logic, configuration naming, backward compatibility, and comprehensive test coverage remain within scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Fix all issues with AI Agents 🤖
In @src/js/netjsongraph.render.js:
- Around line 538-546: The code currently only branches on showMapLabelsAtZoom
=== undefined, so passing showMapLabelsAtZoom: false isn't treated as an
explicit "disable labels" intent; update the resolution logic to explicitly
handle showMapLabelsAtZoom === false as the disabled case (e.g., check if
showMapLabelsAtZoom === false and preserve/flag that state), otherwise run the
existing undefined fallback to self.config.showLabelsAtZoomLevel or 13; ensure
subsequent code that validates numeric zoom treats false as the explicit disable
option rather than an invalid type.
- Line 694: The variable NewZoom uses PascalCase; rename it to camelCase
(newZoom) by changing the declaration "const NewZoom = self.leaflet.getZoom();"
to "const newZoom = self.leaflet.getZoom();" and update every usage of NewZoom
in this module (e.g., any comparisons, assignments, or calls that reference
NewZoom) to newZoom so identifiers remain consistent with JavaScript naming
conventions.
🧹 Nitpick comments (1)
src/js/netjsongraph.render.js (1)

572-572: Consider preserving descriptive variable names.

The variable renames (currentZoomcZoom, showLabelsLabel) reduce readability without clear benefit. The original names were more descriptive and self-documenting.

🔎 Suggested improvement
-      const cZoom = self.leaflet.getZoom();
-      const sLabel = cZoom >= self.config.showLabelsAtZoomLevel;
+      const currentZoom = self.leaflet.getZoom();
+      const showLabel = typeof showMapLabelsAtZoom === "number" && currentZoom >= showMapLabelsAtZoom;
       self.echarts.setOption({
         series: [
           {
             id: "geo-map",
             label: {
-              show: sLabel,
+              show: showLabel,
             },

Also applies to: 579-579

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e503883 and 1f239ae.

📒 Files selected for processing (1)
  • src/js/netjsongraph.render.js
🧰 Additional context used
🪛 GitHub Actions: netjsongraph.js CI BUILD
src/js/netjsongraph.render.js

[warning] 1-1: Code style issues found. Run Prettier with --write to fix.


[error] 1-1: Prettier check failed. Hint: run 'openwisp-qa-format' or 'Prettier --write' to fix code style issues in this file.

🔇 Additional comments (2)
src/js/netjsongraph.render.js (2)

581-585: Good: Emphasis labels remain hidden to prevent overlay overlap.

Setting emphasis.label.show to false unconditionally aligns with the PR objective to prevent label overlap with hover overlays. This ensures that when a user hovers over a node, the overlay tooltip appears without competing with the label.


538-610: The openwisp-qa-format script does not exist in this repository's package.json. Additionally, the code is already properly formatted—Prettier reports no changes needed. The review comment is based on a non-existent issue.

Likely an incorrect or invalid review comment.

Comment thread src/js/netjsongraph.render.js Outdated
Comment thread src/js/netjsongraph.render.js Outdated
@stktyagi
Copy link
Copy Markdown
Member

stktyagi commented Jan 6, 2026

Done please have a look on why ci build failing.

Hey, @Dhruv-ub try running openwisp-qa-format to clear any formatting issues. You can check if it worked by running the run-qa-checks file, ./run-qa-checks next. If it shows no error you are good to go.

@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

Dhruv-ub commented Jan 7, 2026

Done please have a look on why ci build failing.

Hey, @Dhruv-ub try running openwisp-qa-format to clear any formatting issues. You can check if it worked by running the run-qa-checks file, ./run-qa-checks next. If it shows no error you are good to go.

@stktyagi Thanks for suggestion but I already ran that command, still I am having issue.

@stktyagi
Copy link
Copy Markdown
Member

stktyagi commented Jan 9, 2026

Hey, @Dhruv-ub try running openwisp-qa-format to clear any formatting issues. You can check if it worked by running the run-qa-checks file, ./run-qa-checks next. If it shows no error you are good to go.

This worked, you might want to recheck your setup environment.

@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

Dhruv-ub commented Jan 9, 2026

Hey, @Dhruv-ub try running openwisp-qa-format to clear any formatting issues. You can check if it worked by running the run-qa-checks file, ./run-qa-checks next. If it shows no error you are good to go.

This worked, you might want to recheck your setup environment.

Thanks for resolving it, will check it

@nemesifier
Copy link
Copy Markdown
Member

@Dhruv-ub try:

pip install -U --force-reinstall "openwisp-utils[qa] @ https://github.com/openwisp/openwisp-utils/tarball/master"
yarn lint:fix
openwisp-qa-format

@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

netjsongraph.js_.Leaflet.plugins.mp4
Screenshot 2026-02-10 at 9 31 15 AM Almost everything is addressed. The only outstanding item is the .nvmrc missing trailing newline.

@Adityashandilya555 I think you added a video of showMapLabelsAtZoom being set to false.
You should have shown the hover label issue as well.

@nemesifier
Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nemesifier
Copy link
Copy Markdown
Member

@coderabbitai is this ready to merge?

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 10, 2026

Tip

For best results, initiate chat on the files or code changes.

The Comment image shows a geographic map with mountain labels (e.g., “Südliche Wösterspitze 2537 m”, “Ruggles 2270 m”, “Trittwankopf 2482 m”) and a blue node under the cursor. A white tooltip is visible reading:

  • Id: 172.16.40.24
  • Label: Austria-2
    Only the tooltip is interactive; no map label overlap is present, which matches the PR’s intended behavior.

@nemesifier Short answer: from my side this is mergeable, with one tiny docs nit.

Why I think it’s ready

  • Behavior: Labels are now silent and tooltips are explicit and confined; hideDelay is 0. (github.com)
  • Map-label control: The series label honors showMapLabelsAtZoom, and falsy values (false or 0) fully disable labels; zoom/hover updates preserve silent: true. This aligns with our earlier preference to treat 0 as “disabled.” (github.com)
  • Backward-compat: The constructor maps legacy showLabelsAtZoomLevel to showMapLabelsAtZoom and warns once, so existing users aren’t broken. (github.com)
  • CI: The PR shows 5 checks; at least Tests and Coverage (dev) is green (succeeded on Feb 10, 2026), and I don’t see any failing checks on the page. (github.com)

One small follow-up (optional pre-merge, trivial post-merge)

  • README defaults: It still lists showLabelsAtZoomLevel Default: 7 while the code sets both showLabelsAtZoomLevel and showMapLabelsAtZoom to 13. Suggest changing README to:
    • Mark showLabelsAtZoomLevel as a deprecated alias of showMapLabelsAtZoom
    • State Default: 13 (and mention “0 or false disables labels”) (github.com)

If you want, I can open a quick follow-up issue for that README tweak.


🧠 Learnings used
Learnt from: Dhruv-ub
Repo: openwisp/netjsongraph.js PR: 474
File: src/js/netjsongraph.render.js:347-351
Timestamp: 2026-01-30T08:31:21.783Z
Learning: Project preference: treat showMapLabelsAtZoom = 0 as “disabled” (not a valid threshold) and keep falsy checks in src/js/netjsongraph.render.js; document or normalize this if needed.

Learnt from: nemesifier
Repo: openwisp/netjsongraph.js PR: 0
File: :0-0
Timestamp: 2026-02-06T16:33:48.468Z
Learning: In the openwisp/netjsongraph.js project, prioritize pragmatic reviews that focus on critical matters with real user impact (functionality, performance, security, maintainability) over minor code quality details that require significant effort for no noticeable benefit. Avoid perfectionist suggestions when tests pass and functionality is correct.

@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

@coderabbitai is this ready to merge?

Will update as per its requirements and push asap

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 11, 2026

The Comment image shows a geographic map with mountain POIs labeled (e.g., “Südliche Wösterspitze 2537 m”, “Rüggle 2270 m”). A blue node is under the cursor, and a white tooltip is visible with:

  • Id: 172.16.40.24
  • Label: Austria-2
    No map-label/tooltip overlap is present; the tooltip is the interactive overlay while map labels remain non-interactive (silent).

@Dhruv-ub Great—here’s the shortest path to merge:

What’s green right now

  • Behavior: tooltip confine + hideDelay: 0; graph/map labels marked silent; map label visibility keyed to showMapLabelsAtZoom. export default for NetJSONGraphRender is intact. (github.com)
  • Back-compat: constructor maps showLabelsAtZoomLevel → showMapLabelsAtZoom and warns once. (github.com)
  • Defaults/docs/tests: Default showMapLabelsAtZoom = 13 in NetJSONGraphDefaultConfig; README documents showMapLabelsAtZoom and that false disables; a regression browser test verifies label visibility vs zoom. (github.com)
  • CI: “Pre-merge checks | 4 Passed checks” on the PR, and “Tests and Coverage (dev) succeeded Feb 10, 2026” in Checks. (github.com)

What still blocks merge

  • GitHub shows “Requested changes must be addressed to merge this pull request. Awaiting requested review from nemesifier.” After you push your small updates, please Re-request review so the “changes requested” state can be cleared. (github.com)

Nice-to-have (non-blocking)

  • In README, consider adding a one-liner that showLabelsAtZoomLevel is a deprecated alias of showMapLabelsAtZoom, for discoverability. Functionality is already backward compatible. (github.com)

Ping me after your push; I’ll re-run the review immediately.


🧠 Learnings used
Learnt from: Dhruv-ub
Repo: openwisp/netjsongraph.js PR: 474
File: src/js/netjsongraph.render.js:347-351
Timestamp: 2026-01-30T08:31:21.783Z
Learning: Project preference: treat showMapLabelsAtZoom = 0 as “disabled” (not a valid threshold) and keep falsy checks in src/js/netjsongraph.render.js; document or normalize this if needed.

Learnt from: nemesifier
Repo: openwisp/netjsongraph.js PR: 0
File: :0-0
Timestamp: 2026-02-06T16:33:48.468Z
Learning: In the openwisp/netjsongraph.js project, prioritize pragmatic reviews that focus on critical matters with real user impact (functionality, performance, security, maintainability) over minor code quality details that require significant effort for no noticeable benefit. Avoid perfectionist suggestions when tests pass and functionality is correct.
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry it took long for me to review this, it's been a tough period.

It looks mostly good, but on a closer look I still found some issues, see below.

I would appreciate a screen recording that shows how the UI issues have been addressed.

1. Performance: setOption called on every mouseover/mouseout (High)

File: src/js/netjsongraph.render.js:629-667

The mouseover and mouseout handlers each call self.echarts.setOption()
on every single hover event. setOption is not a cheap operation -- it triggers
ECharts' internal diff/merge and re-render pipeline. On a map with hundreds of
nodes, rapidly moving the cursor across multiple nodes will trigger this
repeatedly, potentially causing jank or frame drops.

Suggestion: Debounce the handlers, or track a boolean state flag and skip
the setOption call if the label visibility already matches the desired state.

let labelsCurrentlyHidden = false;

self.echarts.on("mouseover", () => {
  if (!labelsCurrentlyHidden && showMapLabelsAtZoom && ...) {
    labelsCurrentlyHidden = true;
    self.echarts.setOption(/* hide */);
  }
});

self.echarts.on("mouseout", () => {
  if (labelsCurrentlyHidden && showMapLabelsAtZoom && ...) {
    labelsCurrentlyHidden = false;
    self.echarts.setOption(/* show */);
  }
});

2. Event handler accumulation on re-render (Medium)

File: src/js/netjsongraph.render.js:629, 649

self.echarts.on("mouseover", ...) and self.echarts.on("mouseout", ...) are
registered every time mapRender is called. If the user toggles between map
and graph mode via switchMode (see netjsongraph.js:150-176), mapRender
is called again, and new handlers are stacked on top of old ones. Over several
toggles this leads to duplicate handler invocations.

Suggestion: Call self.echarts.off("mouseover") /
self.echarts.off("mouseout") before registering, or use named functions and
off them first.

3. All labels hide on any node hover (Low/UX)

Screencast.from.2026-03-11.16-54-19.mp4

File: src/js/netjsongraph.render.js:629-667

When hovering any node, all labels on the map disappear. The issue
description says "the labels should disappear if there's another overlay
showing up on hover." The current implementation is broader than necessary --
it hides every label rather than just the one overlapping with the tooltip.

It looks quite weird on a busy map. Can we only hide the specific node label being hovered? That's what I was expecting, I wasn't expecting that all labels were hidden.

While testing for this issue, I found another issue: if you change the zoom level, labels are hidden until mouseover, see:

Screencast.from.2026-03-11.16-54-34.mp4

4. Config value captured at render time won't reflect dynamic changes (Low)

File: src/js/netjsongraph.render.js:606

const {showMapLabelsAtZoom} = self.config;

This destructures the value once at render time. The mouseover, mouseout,
and zoomend handlers all close over this captured value. If a consumer
changes self.config.showMapLabelsAtZoom after initial render (e.g., via a
settings UI), the handlers won't see the updated value.

Suggestion: Read from self.config.showMapLabelsAtZoom directly in the
handlers instead of destructuring.

5. animationDuration: 1000 added without clear reason (Low)

File: src/js/netjsongraph.render.js:334

The scatter series now has animationDuration: 1000 added. This wasn't
mentioned in the issue or any commit message. It adds a 1-second animation to
node rendering which could impact perceived performance on large datasets.

6. silent: true also set on graph mode labels (Low)

File: src/js/netjsongraph.render.js:178

baseGraphLabel.silent = true;

The issue is specifically about map mode label/tooltip overlap. Setting
silent: true on graph-mode labels means graph labels also won't respond to
mouse events. This may or may not be desired -- the issue description didn't
mention graph mode labels having overlap problems. If graph labels should remain interactive, this line should be removed.

Question: can you explain why this is added and what effect it has?

Comment thread src/js/netjsongraph.render.js Outdated
Comment thread src/js/netjsongraph.render.js
@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch from 6fedf7c to 7d0bdcf Compare March 14, 2026 20:22
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/js/netjsongraph.render.js`:
- Line 602: Remove the commented-out dead code line referencing
showMapLabelsAtZoom in the rendering module (the line "// const
{showMapLabelsAtZoom} = self.config;") inside src/js/netjsongraph.render.js;
simply delete this unused commented declaration so the file contains no leftover
commented variable destructuring and keep related code (e.g., any uses of
self.config or map label logic) intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 019d870c-b5f6-4c49-8801-61ce226ee353

📥 Commits

Reviewing files that changed from the base of the PR and between 7f12a96 and 6fedf7c.

📒 Files selected for processing (2)
  • src/js/netjsongraph.render.js
  • test/netjsongraph.render.test.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,ts,css,scss,json}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using openwisp-qa-format command with Python virtualenv enabled and yarn lint:fix (runs eslint --fix and prettier via lint-staged)

Files:

  • test/netjsongraph.render.test.js
  • src/js/netjsongraph.render.js
**/*.test.{js,ts}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests using Jest with jsdom and run with yarn test

Files:

  • test/netjsongraph.render.test.js
src/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

Husky pre-commit hooks automatically run lint-staged to format JavaScript files in src/**/*.js with prettier

Files:

  • src/js/netjsongraph.render.js
🧠 Learnings (11)
📓 Common learnings
Learnt from: Dhruv-ub
Repo: openwisp/netjsongraph.js PR: 474
File: src/js/netjsongraph.render.js:347-351
Timestamp: 2026-01-30T08:31:21.783Z
Learning: Project preference: treat showMapLabelsAtZoom = 0 as “disabled” (not a valid threshold) and keep falsy checks in src/js/netjsongraph.render.js; document or normalize this if needed.
Learnt from: nemesifier
Repo: openwisp/netjsongraph.js PR: 0
File: :0-0
Timestamp: 2026-02-06T16:33:48.468Z
Learning: In the openwisp/netjsongraph.js project, prioritize pragmatic reviews that focus on critical matters with real user impact (functionality, performance, security, maintainability) over minor code quality details that require significant effort for no noticeable benefit. Avoid perfectionist suggestions when tests pass and functionality is correct.
📚 Learning: 2026-01-30T08:31:21.783Z
Learnt from: Dhruv-ub
Repo: openwisp/netjsongraph.js PR: 474
File: src/js/netjsongraph.render.js:347-351
Timestamp: 2026-01-30T08:31:21.783Z
Learning: Project preference: treat showMapLabelsAtZoom = 0 as “disabled” (not a valid threshold) and keep falsy checks in src/js/netjsongraph.render.js; document or normalize this if needed.

Applied to files:

  • test/netjsongraph.render.test.js
📚 Learning: 2026-01-20T16:51:06.213Z
Learnt from: codesankalp
Repo: openwisp/netjsongraph.js PR: 425
File: src/js/netjsongraph.render.js:1-26
Timestamp: 2026-01-20T16:51:06.213Z
Learning: In the netjsongraph.js project, imports from `echarts/lib/chart/*/install`, `echarts/lib/component/*/install`, and `echarts/lib/renderer/install*` paths produce better tree-shaking results than the public entry points (`echarts/charts`, `echarts/components`, `echarts/renderers`) in their webpack configuration. The project maintainer has tested both approaches and confirmed the `/lib/*/install` pattern yields smaller bundles.

Applied to files:

  • test/netjsongraph.render.test.js
📚 Learning: 2026-01-22T22:37:11.271Z
Learnt from: CR
Repo: openwisp/netjsongraph.js PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-22T22:37:11.271Z
Learning: Applies to test/netjsongraph.browser.test.js : Write browser tests in test/netjsongraph.browser.test.js using Chrome/ChromeDriver and run with `yarn test test/netjsongraph.browser.test.js`

Applied to files:

  • test/netjsongraph.render.test.js
📚 Learning: 2026-02-06T16:33:48.468Z
Learnt from: nemesifier
Repo: openwisp/netjsongraph.js PR: 0
File: :0-0
Timestamp: 2026-02-06T16:33:48.468Z
Learning: In the openwisp/netjsongraph.js project, prioritize pragmatic reviews that focus on critical matters with real user impact (functionality, performance, security, maintainability) over minor code quality details that require significant effort for no noticeable benefit. Avoid perfectionist suggestions when tests pass and functionality is correct.

Applied to files:

  • test/netjsongraph.render.test.js
  • src/js/netjsongraph.render.js
📚 Learning: 2026-01-24T23:09:24.928Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 444
File: src/js/netjsongraph.util.js:1404-1442
Timestamp: 2026-01-24T23:09:24.928Z
Learning: In the `moveNodeInRealTime` function in `src/js/netjsongraph.util.js`, it is recommended that `node.properties` be set, and the function should return early when `properties` is not provided rather than initializing it or handling it gracefully.

Applied to files:

  • test/netjsongraph.render.test.js
  • src/js/netjsongraph.render.js
📚 Learning: 2026-01-27T19:09:23.929Z
Learnt from: nemesifier
Repo: openwisp/netjsongraph.js PR: 473
File: src/js/netjsongraph.render.js:433-468
Timestamp: 2026-01-27T19:09:23.929Z
Learning: In the netjsongraph.js project, when implementing wheel zoom propagation from the graph container to the canvas: ECharts intercepts wheel events directly on the canvas with preventDefault(), so those events don't bubble to the container. A wheel listener on the container only catches events that occur outside the canvas (in the empty container space), making checks for e.target === canvas unnecessary since canvas events never reach the container listener.

Applied to files:

  • test/netjsongraph.render.test.js
  • src/js/netjsongraph.render.js
📚 Learning: 2026-01-20T00:56:36.062Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 417
File: src/js/netjsongraph.core.js:132-145
Timestamp: 2026-01-20T00:56:36.062Z
Learning: In the netjsongraph.js codebase, the data model does not support parallel links (multiple links between the same source and target). Ensure nodeLinkIndex is keyed by a single 'source~target' pair and that adding a link does not overwrite existing links for that pair. If parallel links are ever required, the data model must be changed (e.g., allow an array of links per 'source~target' key) rather than storing only one link.

Applied to files:

  • test/netjsongraph.render.test.js
  • src/js/netjsongraph.render.js
📚 Learning: 2026-01-30T08:31:13.746Z
Learnt from: Dhruv-ub
Repo: openwisp/netjsongraph.js PR: 474
File: src/js/netjsongraph.render.js:347-351
Timestamp: 2026-01-30T08:31:13.746Z
Learning: In src/js/netjsongraph.render.js, treat showMapLabelsAtZoom = 0 as the explicit 'disabled' state (not a valid threshold). Do not rely on generic falsy checks for this flag. Update logic to distinguish between undefined/null (not set), 0 (disabled), and >0 (enabled at a given zoom). For example, use explicit checks such as: if (showMapLabelsAtZoom === 0) { /* labels hidden */ } else if (typeof showMapLabelsAtZoom === 'number' && showMapLabelsAtZoom > 0) { /* show labels at/above this zoom */ } else { /* default behavior or undefined */ }. If needed, document this convention or normalize input (e.g., set undefined to a sensible default) to avoid ambiguity in future reviews.

Applied to files:

  • src/js/netjsongraph.render.js
📚 Learning: 2026-01-20T16:50:56.414Z
Learnt from: codesankalp
Repo: openwisp/netjsongraph.js PR: 425
File: src/js/netjsongraph.render.js:1-26
Timestamp: 2026-01-20T16:50:56.414Z
Learning: In netjsongraph.js, prefer importing from echarts/lib/chart/*/install, echarts/lib/component/*/install, and echarts/lib/renderer/install* rather than the public entry points (echarts/charts, echarts/components, echarts/renderers) to improve tree-shaking and reduce bundle size. Apply this pattern across JS files in src (update imports accordingly) and verify by comparing bundle sizes between the install-path imports and the public-entry imports.

Applied to files:

  • src/js/netjsongraph.render.js
📚 Learning: 2026-01-04T08:00:40.936Z
Learnt from: dee077
Repo: openwisp/netjsongraph.js PR: 417
File: src/js/netjsongraph.util.js:1302-1341
Timestamp: 2026-01-04T08:00:40.936Z
Learning: In the netjsongraph.js codebase, the `== null` pattern is intentionally used to check for both null and undefined values in a single comparison, which is a well-established JavaScript idiom and should not be flagged for replacement with strict equality checks.

Applied to files:

  • src/js/netjsongraph.render.js
🔇 Additional comments (15)
src/js/netjsongraph.render.js (6)

60-60: LGTM!

Setting hideDelay: 0 ensures the tooltip disappears immediately, improving predictability and aligning with the PR objective of making tooltip behavior explicit.


331-335: LGTM!

The label configuration correctly merges existing config, conditionally hides labels when showMapLabelsAtZoom is falsy, and sets silent: true to prevent hover event capture. This addresses the PR objective of making labels non-interactive.


603-623: LGTM!

The initial label visibility logic correctly hides labels when showMapLabelsAtZoom is falsy or when the current zoom is below the threshold. The silent: true flag ensures labels don't capture hover events.


625-633: LGTM!

The empty handlers are appropriately retained for test compatibility. ECharts natively handles label visibility through the emphasis: { label: { show: false } } configuration, making explicit setOption calls unnecessary.


635-655: LGTM!

The zoomend handler correctly evaluates label visibility dynamically, maintaining silent: true and keeping emphasis labels hidden to prevent redundancy with tooltips.


754-766: LGTM!

The cluster click handler now zooms to currentZoom + 2 (capped at max zoom) instead of just expanding, providing better user interaction for navigating into clusters.

test/netjsongraph.render.test.js (9)

981-981: LGTM!

Adding the on: jest.fn() mock correctly supports testing the new echarts event handler registration.


1081-1086: LGTM!

The config field rename to showMapLabelsAtZoom and echarts mock update align with the implementation changes.


1224-1239: LGTM!

The config update and the echartsSetOption delegation to mockSelf.echarts.setOption allow proper tracking of setOption calls in tests.


1275-1285: LGTM!

The comments clearly explain the expected call count logic: 1 (initial render) + 1 (moveend update) = 2. This makes the test intention clear.


1473-1479: LGTM!

Consistent updates to use the renamed config field and mock echarts event registration.


1506-1563: LGTM!

The test setup properly configures mocks for testing label/tooltip interaction, including the key silent: true property in the mock return value.


1565-1584: LGTM!

These tests verify that labels remain silent: true both on initial render and after zoomend events, ensuring labels don't capture hover events.


1586-1606: LGTM!

This test verifies that the mouseover/mouseout handlers are registered and callable without errors. Since the handlers are intentionally no-ops (ECharts handles label visibility natively via emphasis config), no assertions are needed beyond verifying registration.


1608-1670: LGTM!

Comprehensive test coverage for the "labels completely disabled" scenario when showMapLabelsAtZoom is false. The test correctly verifies:

  • Initial label hiding via setOption
  • Labels remain hidden at high zoom (zoomend)
  • Labels remain hidden at low zoom (zoomend)
  • Hover/unhover handlers don't error when labels are disabled

Comment thread src/js/netjsongraph.render.js Outdated
- Optimize ECharts setOption to prevent hover frame drops
- Clean up event handlers on re-render to avoid duplication
- Hide only hovered node label and fix zoom visibility bug
- Read config state dynamically
- Disable cluster animation and remove graph label silent flag
@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch from 7d0bdcf to 2699d01 Compare March 14, 2026 20:46
@Dhruv-ub
Copy link
Copy Markdown
Contributor Author

Node.Label.Testing.mp4

Here is the testing video for the issue

@Dhruv-ub Dhruv-ub requested a review from nemesifier March 15, 2026 05:47
nemesifier
nemesifier previously approved these changes Apr 22, 2026
Copy link
Copy Markdown
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some bugs, I fixed any issue I encountered and it should be ready now.
@Dhruv-ub please double check when you can.
@coderabbitai review one last time, focus on real issues, approve if ready.

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented Apr 22, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Files Reviewed (7 files)
  • README.md - Documentation updated correctly with new option name and behavior
  • src/js/netjsongraph.config.js - Config default updated to showMapLabelsAtZoom
  • src/js/netjsongraph.js - Backward compatibility handling for old config name
  • src/js/netjsongraph.render.js - Label visibility logic properly refactored with updateLabelVisibility() helper
  • src/js/netjsongraph.util.js - FIXED: Now correctly uses showMapLabelsAtZoom
  • test/netjsongraph.browser.test.js - Good regression test for label zoom behavior
  • test/netjsongraph.render.test.js - Comprehensive test coverage for new functionality

Previous Issue Resolution

RESOLVED: The critical issue from the previous review (incomplete config rename in netjsongraph.util.js) has been fixed. Line 1379 now correctly references showMapLabelsAtZoom instead of the old showLabelsAtZoomLevel.

Summary

The PR successfully:

  • Renames showLabelsAtZoomLevel to showMapLabelsAtZoom for consistency
  • Maintains backward compatibility with deprecation warning
  • Adds proper label visibility control (false to disable, 0 for always show, positive number for zoom threshold)
  • Makes labels non-interactive (silent: true) to prevent tooltip conflicts
  • Adds comprehensive test coverage including browser regression test
  • Updates documentation

All changes align with the issue #454 requirements.


Reviewed by kimi-k2.5-0127 · 493,729 tokens

Copy link
Copy Markdown
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai review

@nemesifier
Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nemesifier nemesifier merged commit 2b9c266 into openwisp:master Apr 22, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in OpenWISP Contributor's Board Apr 22, 2026
@nemesifier nemesifier changed the title [fix] Resolve redundant node labels and overlays #454 [fix] Fixed redundant node labels and overlays #454 Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug javascript Pull requests that update Javascript code

Projects

Development

Successfully merging this pull request may close these issues.

[bug] Node labels and overlays are redundant

4 participants