From f2178644f60ce3b8ac1050bfe2c408ac5cb840a5 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 12 Apr 2023 20:43:59 +0530 Subject: [PATCH] [change] Graph mode respects showLabelsAtZoomLevel setting #148 Closes #148 --- src/js/netjsongraph.render.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/js/netjsongraph.render.js b/src/js/netjsongraph.render.js index c712b9e6..817c87e4 100644 --- a/src/js/netjsongraph.render.js +++ b/src/js/netjsongraph.render.js @@ -296,6 +296,38 @@ class NetJSONGraphRender { self.echarts.resize(); }; + if ( + self.echarts.getOption().series[0].zoom < + self.config.showLabelsAtZoomLevel + ) { + self.echarts.setOption({ + series: [ + { + label: { + show: false, + }, + }, + ], + }); + } + + self.echarts.on("graphRoam", (e) => { + if ( + self.echarts.getOption().series[0].zoom >= + self.config.showLabelsAtZoomLevel + ) { + self.echarts.setOption({ + series: [ + { + label: { + show: true, + }, + }, + ], + }); + } + }); + self.event.emit("onLoad"); self.event.emit("onReady"); self.event.emit("renderArray"); @@ -421,7 +453,6 @@ class NetJSONGraphRender { self.leaflet.geoJSON.addTo(self.leaflet); } } - if (self.leaflet.getZoom() < self.config.showLabelsAtZoomLevel) { self.echarts.setOption({ series: [