Skip to content

Commit 94bc1c2

Browse files
committed
1.Hover overlay origin
The overlay comes from the default ECharts tooltip. In this PR it’s made explicit and more predictable (confined to viewport, no hide delay). 2.Disabling map labels Now they can be disabled completely if showMapLabelsAtZoom is set to false. showLabelsAtZoomLevel is still supported internally for backward compatibility. 3.Overlap between labels and hover overlays The main cause was labels being interactive. Both graph and map labels are now marked as silent, so tooltips always have interaction priority and overlap no longer causes UX issues. 4.Default behavior and redundancy Labels remain the default, non-invasive layer (shown only above a zoom threshold), while tooltips remain the primary interactive overlay. 5.Config naming consistency showLabelsAtZoomLevel (map) is effectively renamed to showMapLabelsAtZoom, aligning it with showGraphLabelsAtZoom, while keeping backward compatibility.
1 parent cc68e9e commit 94bc1c2

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/js/netjsongraph.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const NetJSONGraphDefaultConfig = {
4141
clusterRadius: 80,
4242
clusterSeparation: 20,
4343
showMetaOnNarrowScreens: false,
44-
showLabelsAtZoomLevel: 13,
44+
showMapLabelsAtZoom: 13,
4545
showGraphLabelsAtZoom: null,
4646
crs: L.CRS.EPSG3857,
4747
echartsOption: {

src/js/netjsongraph.render.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class NetJSONGraphRender {
4747

4848
tooltip: {
4949
confine: true,
50+
hideDelay: 0,
5051
position: (pos, params, dom, rect, size) => {
5152
let position = "right";
5253
if (size.viewSize[0] - pos[0] < size.contentSize[0]) {
@@ -170,6 +171,9 @@ class NetJSONGraphRender {
170171
const baseGraphSeries = {...configs.graphConfig.series};
171172
const baseGraphLabel = {...(baseGraphSeries.label || {})};
172173

174+
// Added this for label hover issue
175+
baseGraphLabel.silent = true;
176+
173177
// Shared helper to get current graph zoom level
174178
const getGraphZoom = () => {
175179
try {
@@ -332,7 +336,10 @@ class NetJSONGraphRender {
332336
coordinateSystem: "leaflet",
333337
data: nodesData,
334338
animationDuration: 1000,
335-
label: configs.mapOptions.nodeConfig.label,
339+
label: {
340+
...(configs.mapOptions.nodeConfig.label || {}),
341+
silent: true,
342+
},
336343
itemStyle: {
337344
color: (params) => {
338345
if (
@@ -538,15 +545,15 @@ class NetJSONGraphRender {
538545
// 4. Resolve label visibility threshold
539546
let {showMapLabelsAtZoom} = self.config;
540547
if (showMapLabelsAtZoom === undefined) {
541-
if (self.config.showLabelsAtZoomLevel !== undefined) {
542-
showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
548+
if (self.config.showMapLabelsAtZoom !== undefined) {
549+
showMapLabelsAtZoom = self.config.showMapLabelsAtZoom;
543550
} else {
544551
showMapLabelsAtZoom = 13;
545552
}
546553
}
547554

548-
const currentZoom = self.leaflet.getZoom();
549-
const showLabel =
555+
let currentZoom = self.leaflet.getZoom();
556+
let showLabel =
550557
typeof showMapLabelsAtZoom === "number" && currentZoom >= showMapLabelsAtZoom;
551558

552559
if (!showLabel) {
@@ -556,6 +563,7 @@ class NetJSONGraphRender {
556563
id: "geo-map",
557564
label: {
558565
show: false,
566+
silent: true,
559567
},
560568
emphasis: {
561569
label: {
@@ -568,14 +576,15 @@ class NetJSONGraphRender {
568576
}
569577

570578
self.leaflet.on("zoomend", () => {
571-
const cZoom = self.leaflet.getZoom();
572-
const sLabel = cZoom >= self.config.showLabelsAtZoomLevel;
579+
currentZoom = self.leaflet.getZoom();
580+
showLabel = currentZoom >= self.config.showMapLabelsAtZoom;
573581
self.echarts.setOption({
574582
series: [
575583
{
576584
id: "geo-map",
577585
label: {
578-
show: sLabel,
586+
show: showLabel,
587+
silent: true,
579588
},
580589
emphasis: {
581590
label: {
@@ -594,13 +603,13 @@ class NetJSONGraphRender {
594603
const zoomOut = document.querySelector(".leaflet-control-zoom-out");
595604

596605
if (zoomIn && zoomOut) {
597-
if (Math.round(cZoom) >= maxZoom) {
606+
if (Math.round(currentZoom) >= maxZoom) {
598607
zoomIn.classList.add("leaflet-disabled");
599608
} else {
600609
zoomIn.classList.remove("leaflet-disabled");
601610
}
602611

603-
if (Math.round(cZoom) <= minZoom) {
612+
if (Math.round(currentZoom) <= minZoom) {
604613
zoomOut.classList.add("leaflet-disabled");
605614
} else {
606615
zoomOut.classList.remove("leaflet-disabled");

0 commit comments

Comments
 (0)