Skip to content

Conversation

@Dhruv-ub
Copy link

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

Updated mapRender to hide emphasis labels on hover to prevent overlap with overlays.
Ensures better visibility by preventing label clutter when interacting with map elements.

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

  • Updated mapRender to hide emphasis labels on hover to prevent overlap with overlays.
  • If showLabelsAtZoomLevel is set to false, labels will not display at any zoom level.

Screenshot

IMG20251216200740

@Dhruv-ub
Copy link
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
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
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
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
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.

@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 4 times, most recently from f016515 to 93eed68 Compare December 26, 2025 14:50
Updated mapRender to hide emphasis labels on hover to prevent overlap with overlays.

Ensures labels do not overlap with other map elements when hovering.

Fixes openwisp#454
@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch from c6c106d to 465e1e7 Compare December 26, 2025 16:28
@Dhruv-ub
Copy link
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
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 4 times, most recently from baac701 to a685e69 Compare December 27, 2025 16:14
@Dhruv-ub Dhruv-ub force-pushed the issues/454-fix-redundant-labels branch from a685e69 to 1f239ae Compare December 27, 2025 16:21
@Dhruv-ub
Copy link
Author

Done please have a look on why ci build failing.

@nemesifier
Copy link
Member

@coderabbitai review

@coderabbitai
Copy link

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

coderabbitai bot commented Jan 5, 2026

Walkthrough

The change addresses redundant node label and overlay visibility in the geo-map component by introducing a configurable zoom threshold for map label display. A new showMapLabelsAtZoom configuration option is added with fallback logic to the legacy showLabelsAtZoomLevel option (defaulting to zoom level 13 if unspecified). The zoom event handlers and cluster-click logic are updated to compute current zoom and determine label visibility by comparing against this threshold. When the zoom level falls below the threshold, map labels and their emphasis states are suppressed. Variable names in zoom-related paths are refactored for consistency (e.g., currentZoom to cZoom, showLabel to sLabel).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main objective of fixing redundant node labels and overlays issue #454, making it clear and specific.
Description check ✅ Passed The PR description follows the template with all required sections completed, including checklist, issue reference, detailed changes, and screenshot.
Linked Issues check ✅ Passed The changes address all key requirements from issue #454: hiding labels on hover to prevent overlap, supporting showLabelsAtZoomLevel=false to disable labels, and implementing the map label visibility threshold logic.
Out of Scope Changes check ✅ Passed All code changes in the PR are directly focused on resolving the redundant labels and overlays issue; no unrelated modifications were introduced.
✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link

@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 on lines +538 to +546
// 4. Resolve label visibility threshold
let {showMapLabelsAtZoom} = self.config;
if (showMapLabelsAtZoom === undefined) {
if (self.config.showLabelsAtZoomLevel !== undefined) {
showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
} else {
showMapLabelsAtZoom = 13;
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle showMapLabelsAtZoom: false to disable labels entirely.

According to the PR objectives, setting showMapLabelsAtZoom to false should disable labels entirely. The current logic only checks for undefined, so false will pass through and fail the type check at line 550, resulting in labels being hidden (which may be the desired outcome) but not for the right reasons. Make the intent explicit by handling the false case.

🔎 Proposed fix
-    // 4. Resolve label visibility threshold
-    let {showMapLabelsAtZoom} = self.config;
-    if (showMapLabelsAtZoom === undefined) {
-      if (self.config.showLabelsAtZoomLevel !== undefined) {
-        showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
-      } else {
-        showMapLabelsAtZoom = 13;
-      }
-    }
+    // 4. Resolve label visibility threshold
+    let {showMapLabelsAtZoom} = self.config;
+    if (showMapLabelsAtZoom === undefined) {
+      if (self.config.showLabelsAtZoomLevel !== undefined) {
+        showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
+      } else {
+        showMapLabelsAtZoom = 13;
+      }
+    }
+    // Explicitly handle false to disable labels
+    if (showMapLabelsAtZoom === false) {
+      showMapLabelsAtZoom = Infinity; // Never show labels
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 4. Resolve label visibility threshold
let {showMapLabelsAtZoom} = self.config;
if (showMapLabelsAtZoom === undefined) {
if (self.config.showLabelsAtZoomLevel !== undefined) {
showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
} else {
showMapLabelsAtZoom = 13;
}
}
// 4. Resolve label visibility threshold
let {showMapLabelsAtZoom} = self.config;
if (showMapLabelsAtZoom === undefined) {
if (self.config.showLabelsAtZoomLevel !== undefined) {
showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
} else {
showMapLabelsAtZoom = 13;
}
}
// Explicitly handle false to disable labels
if (showMapLabelsAtZoom === false) {
showMapLabelsAtZoom = Infinity; // Never show labels
}
🤖 Prompt for AI Agents
In @src/js/netjsongraph.render.js around lines 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.

const currentZoom = self.leaflet.getZoom();
const showLabel = currentZoom >= self.config.showLabelsAtZoomLevel;
const cZoom = self.leaflet.getZoom();
const sLabel = cZoom >= self.config.showLabelsAtZoomLevel;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Use the computed showMapLabelsAtZoom threshold, not the legacy property.

Line 573 directly references self.config.showLabelsAtZoomLevel, bypassing the threshold resolution logic established at lines 538-546. This breaks the new showMapLabelsAtZoom configuration option and the fallback mechanism. If showLabelsAtZoomLevel is undefined, this will result in NaN comparisons.

🔎 Proposed fix
-      const sLabel = cZoom >= self.config.showLabelsAtZoomLevel;
+      const sLabel = typeof showMapLabelsAtZoom === "number" && cZoom >= showMapLabelsAtZoom;

Note: You'll need to ensure showMapLabelsAtZoom is accessible in the zoomend handler scope. Consider storing it in self.config or declaring it in a broader scope.

Committable suggestion skipped: line range outside the PR's diff.

// Zoom into the clicked cluster instead of expanding it
const currentZoom = self.leaflet.getZoom();
const targetZoom = Math.min(currentZoom + 2, self.leaflet.getMaxZoom());
const NewZoom = self.leaflet.getZoom();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use camelCase for the zoom variable.

NewZoom uses PascalCase, which is conventionally reserved for constructors and classes in JavaScript. Use camelCase for consistency with language conventions.

🔎 Proposed fix
-          const NewZoom = self.leaflet.getZoom();
-          const targetZoom = Math.min(NewZoom + 2, self.leaflet.getMaxZoom());
+          const currentZoom = self.leaflet.getZoom();
+          const targetZoom = Math.min(currentZoom + 2, self.leaflet.getMaxZoom());

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @src/js/netjsongraph.render.js around 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.

@stktyagi
Copy link
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
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
Member

stktyagi commented Jan 7, 2026

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

Can you show me what you see after running openwisp-qa-format?
Let's talk about this in the dev chat to keep this PR with comments only related to the main issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Node labels and overlays are redundant

3 participants