From bd958b68fd6427a1b075684262c00f61b5d0a2e0 Mon Sep 17 00:00:00 2001 From: Dani Pinyol Date: Tue, 12 Mar 2024 10:50:36 +0100 Subject: [PATCH 1/3] change handler to only local logger All handlers are removed from the root logger and replace by a handler which logs with "[d3graph]" prefix. This causes that this prefix appears in logs from other modules. It also interferes with pytest log handles. This PR performs the handler replacement only for the local logger. --- d3graph/d3graph.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/d3graph/d3graph.py b/d3graph/d3graph.py index 8b8991e..61c29c3 100644 --- a/d3graph/d3graph.py +++ b/d3graph/d3graph.py @@ -25,14 +25,13 @@ from packaging import version import datazets as dz -logger = logging.getLogger('') +logger = logging.getLogger(__name__) for handler in logger.handlers[:]: logger.removeHandler(handler) console = logging.StreamHandler() formatter = logging.Formatter('[d3graph] %(levelname)s> %(message)s') console.setFormatter(formatter) logger.addHandler(console) -logger = logging.getLogger(__name__) # %% From 5d83d6287c48574a1ef57d278ac3ac755082146d Mon Sep 17 00:00:00 2001 From: Dani Pinyol Date: Thu, 18 Apr 2024 15:48:13 +0200 Subject: [PATCH 2/3] remove markupsafe transitive dependency constraint --- requirements.txt | 1 - setup.py | 1 - 2 files changed, 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index f8da85f..9dab12d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ colourmap ismember jinja2 -markupsafe==2.0.1 networkx>2 numpy packaging diff --git a/setup.py b/setup.py index 76ffeec..b298611 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,6 @@ 'ismember', 'jinja2', 'packaging', - 'markupsafe==2.0.1', 'python-louvain', 'datazets'], python_requires='>=3', From 7589acad75ced9b1464fdc643c3926d25438de26 Mon Sep 17 00:00:00 2001 From: guillem-avatar Date: Mon, 10 Jun 2024 14:53:33 +0200 Subject: [PATCH 3/3] feat: add tooltip for edge properties --- d3graph/d3graph.py | 5 +++++ d3graph/d3js/d3graphscript.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/d3graph/d3graph.py b/d3graph/d3graph.py index 61c29c3..5c26522 100644 --- a/d3graph/d3graph.py +++ b/d3graph/d3graph.py @@ -893,6 +893,7 @@ def json_create(G: nx.Graph) -> str: links[i]['label'] = links[i]['label'] links[i]['label_color'] = links[i]['label_color'] links[i]['label_fontsize'] = links[i]['label_fontsize'] + links[i]['tooltip'] = links[i]['tooltip'] links_new.append(links[i]) # Set node properties @@ -999,6 +1000,7 @@ def adjmat2dict(adjmat: pd.DataFrame, 'label': Text label for the edge. 'label_color': color of the label. 'label_fontsize': fontsize of the label. + 'tooltip': Text that is shown when hovering over the edge. """ # Convert adjacency matrix into vector @@ -1053,6 +1055,7 @@ def adjmat2dict(adjmat: pd.DataFrame, df['label_color']=label_color df['label_fontsize']=label_fontsize df['edge_style']=edge_style + df['tooltip'] = df['weight'].astype(str) # Creation dictionary source_target = list(zip(df['source'], df['target'])) @@ -1069,6 +1072,7 @@ def adjmat2dict(adjmat: pd.DataFrame, 'label': df['label'].iloc[i], 'label_color': df['label_color'].iloc[i], 'label_fontsize': df['label_fontsize'].iloc[i], + 'tooltip': df['tooltip'].iloc[i] } for i, edge in enumerate(source_target)} @@ -1144,6 +1148,7 @@ def edges2G(edge_properties: dict, G: nx.Graph = None) -> nx.Graph: label=edge_properties[edge]['label'], label_color=edge_properties[edge]['label_color'], label_fontsize=edge_properties[edge]['label_fontsize'], + tooltip=edge_properties[edge]['tooltip'] ) return G diff --git a/d3graph/d3js/d3graphscript.js b/d3graph/d3js/d3graphscript.js index 22df1bc..2e45fd4 100644 --- a/d3graph/d3js/d3graphscript.js +++ b/d3graph/d3js/d3graphscript.js @@ -75,6 +75,8 @@ function d3graphscript(config = { // .style("stroke-width", 1); // WIDTH OF THE LINKS ; + link.append("title").text(function(d) { return d.tooltip; }); + // ADD TEXT ON THE EDGES (PART 1/2) var linkText = svg.selectAll(".link-text") .data(graph.links)