neo4j-viz 0.6.0__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,5 +49,17 @@ button.icon:active {
49
49
  filter: drop-shadow(0 4px 8px rgba(26,27,29,0.12));
50
50
  font-family: 'Public Sans', sans-serif;
51
51
  color: var(--neutral-text-default);
52
- font-size: 14px
52
+ font-size: 14px;
53
+ overflow-y: auto;
54
+ overflow-x: hidden;
55
+ word-wrap: break-word;
56
+ overflow-wrap: break-word;
57
+ }
58
+
59
+ .tooltip-value {
60
+ display: inline-block;
61
+ max-width: 100%;
62
+ overflow: hidden;
63
+ text-overflow: ellipsis;
64
+ white-space: nowrap;
53
65
  }
neo4j_viz/snowflake.py CHANGED
@@ -341,9 +341,9 @@ def from_snowflake(
341
341
  VG = from_dfs(node_dfs, rel_dfs)
342
342
 
343
343
  for node in VG.nodes:
344
- node.caption = node.properties.get("table")
344
+ node.caption = node.properties.pop("table")
345
345
  for rel in VG.relationships:
346
- rel.caption = rel.properties.get("table")
346
+ rel.caption = rel.properties.pop("table")
347
347
 
348
348
  number_of_colors = node_df["table"].drop_duplicates().count()
349
349
  if number_of_colors <= len(NEO4J_COLORS_DISCRETE):
@@ -194,6 +194,75 @@ class VisualizationGraph:
194
194
 
195
195
  node.pinned = node_pinned
196
196
 
197
+ def set_node_captions(
198
+ self,
199
+ *,
200
+ field: Optional[str] = None,
201
+ property: Optional[str] = None,
202
+ override: bool = True,
203
+ ) -> None:
204
+ """
205
+ Set the caption for nodes in the graph based on either a node field or a node property.
206
+
207
+ Parameters
208
+ ----------
209
+ field:
210
+ The field of the nodes to use as the caption. Must be None if `property` is provided.
211
+ property:
212
+ The property of the nodes to use as the caption. Must be None if `field` is provided.
213
+ override:
214
+ Whether to override existing captions of the nodes, if they have any.
215
+
216
+ Examples
217
+ --------
218
+ Given a VisualizationGraph `VG`:
219
+
220
+ >>> nodes = [
221
+ ... Node(id="0", properties={"name": "Alice", "age": 30}),
222
+ ... Node(id="1", properties={"name": "Bob", "age": 25}),
223
+ ... ]
224
+ >>> VG = VisualizationGraph(nodes=nodes)
225
+
226
+ Set node captions from a property:
227
+
228
+ >>> VG.set_node_captions(property="name")
229
+
230
+ Set node captions from a field, only if not already set:
231
+
232
+ >>> VG.set_node_captions(field="id", override=False)
233
+
234
+ Set captions from multiple properties with fallback:
235
+
236
+ >>> for node in VG.nodes:
237
+ ... caption = node.properties.get("name") or node.properties.get("title") or node.id
238
+ ... if override or node.caption is None:
239
+ ... node.caption = str(caption)
240
+ """
241
+ if not ((field is None) ^ (property is None)):
242
+ raise ValueError(
243
+ f"Exactly one of the arguments `field` (received '{field}') and `property` (received '{property}') must be provided"
244
+ )
245
+
246
+ if property:
247
+ # Use property
248
+ for node in self.nodes:
249
+ if not override and node.caption is not None:
250
+ continue
251
+
252
+ value = node.properties.get(property, "")
253
+ node.caption = str(value)
254
+ else:
255
+ # Use field
256
+ assert field is not None
257
+ attribute = to_snake(field)
258
+
259
+ for node in self.nodes:
260
+ if not override and node.caption is not None:
261
+ continue
262
+
263
+ value = getattr(node, attribute, "")
264
+ node.caption = str(value)
265
+
197
266
  def resize_nodes(
198
267
  self,
199
268
  sizes: Optional[dict[NodeIdType, RealNumber]] = None,
@@ -294,7 +363,7 @@ class VisualizationGraph:
294
363
  property: Optional[str] = None,
295
364
  colors: Optional[ColorsType] = None,
296
365
  color_space: ColorSpace = ColorSpace.DISCRETE,
297
- override: bool = False,
366
+ override: bool = True,
298
367
  ) -> None:
299
368
  """
300
369
  Color the nodes in the graph based on either a node field, or a node property.
@@ -1,15 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neo4j-viz
3
- Version: 0.6.0
3
+ Version: 1.0.0
4
4
  Summary: A simple graph visualization tool
5
5
  Author-email: Neo4j <team-gds@neo4j.org>
6
6
  License-Expression: GPL-3.0-only
7
7
  Project-URL: Homepage, https://neo4j.com/
8
8
  Project-URL: Repository, https://github.com/neo4j/python-graph-visualization
9
9
  Project-URL: Issues, https://github.com/neo4j/python-graph-visualization/issues
10
- Project-URL: Documentation, https://neo4j.com/docs/nvl-python/preview
10
+ Project-URL: Documentation, https://neo4j.com/docs/python-graph-visualization/
11
11
  Keywords: graph,visualization,neo4j
12
- Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Science/Research
15
15
  Classifier: Operating System :: OS Independent
@@ -34,7 +34,7 @@ Requires-Dist: pydantic-extra-types<3,>=2
34
34
  Requires-Dist: enum-tools==0.13.0
35
35
  Provides-Extra: dev
36
36
  Requires-Dist: ruff==0.14.1; extra == "dev"
37
- Requires-Dist: mypy==1.17.1; extra == "dev"
37
+ Requires-Dist: mypy==1.18.2; extra == "dev"
38
38
  Requires-Dist: pytest==8.4.2; extra == "dev"
39
39
  Requires-Dist: selenium==4.32.0; extra == "dev"
40
40
  Requires-Dist: ipykernel==6.30.1; extra == "dev"
@@ -10,18 +10,18 @@ neo4j_viz/options.py,sha256=oai-yI03WxWyl6-9cFWEbQkqpXAcI8oG4G6rSVF1Bt0,6495
10
10
  neo4j_viz/pandas.py,sha256=gFQW9SlWxiSrVCi2kHGUKpDXDhYtlFkk2AR2DzxYTWE,4759
11
11
  neo4j_viz/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  neo4j_viz/relationship.py,sha256=aVj8_6umHSm1rg53CU-oci21W845J91AFKv1AJudmD8,4112
13
- neo4j_viz/snowflake.py,sha256=GoiFfpzE5fuAorh_PNZCK7QSIv52pIMn_QS2LLsUxCM,12683
14
- neo4j_viz/visualization_graph.py,sha256=v2OmfGM8t9UDmSDCFLe5uWa6MnPmppby20VK_NjThT4,17161
13
+ neo4j_viz/snowflake.py,sha256=Md3bW6qaBVnq8A_2fx8POkdbpKQuPc1qNaNzwDvQ8CE,12683
14
+ neo4j_viz/visualization_graph.py,sha256=G4MHAQ_sgVMDqf3gI76l4m8tnFzfW0hM_lrxWFWojVc,19490
15
15
  neo4j_viz/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  neo4j_viz/resources/icons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  neo4j_viz/resources/icons/screenshot.svg,sha256=Ns9Yi2Iq4lIaiFvzc0pXBmjxt4fcmBO-I4cI8Xiu1HE,311
18
18
  neo4j_viz/resources/icons/zoom-in.svg,sha256=PsO5yFkA1JnGM2QV_qxHKG13qmoR-RrlWARpaXNp5qU,415
19
19
  neo4j_viz/resources/icons/zoom-out.svg,sha256=OQRADAoe2bxbCeFufg6W22nR41q5NlI8QspT9l5pXUw,400
20
20
  neo4j_viz/resources/nvl_entrypoint/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- neo4j_viz/resources/nvl_entrypoint/base.js,sha256=tICNjZLV8sUen2qvosUZuUlovpHcZIqXpdNzSo4phE4,1820159
22
- neo4j_viz/resources/nvl_entrypoint/styles.css,sha256=JjeTSB9OJT2KMfb8yFUUMLMG7Rzrf3o60hSCD547zTk,1123
23
- neo4j_viz-0.6.0.dist-info/licenses/LICENSE,sha256=tWSeLI0mRp2u8Pnumaxq51JltfXLVSXl2w_D6kxhRMI,36006
24
- neo4j_viz-0.6.0.dist-info/METADATA,sha256=A06tmKgiAI93yfZRX-ofAapiQeJldwSCKkCegzf_LG0,7120
25
- neo4j_viz-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- neo4j_viz-0.6.0.dist-info/top_level.txt,sha256=jPUM3z8MOtxqDanc2VzqkxG4HJn8aaq4S7rnCFNk_Vs,10
27
- neo4j_viz-0.6.0.dist-info/RECORD,,
21
+ neo4j_viz/resources/nvl_entrypoint/base.js,sha256=2Z_ofAXO1TFONMqYXjBjPd6l4U3an-h8ZNwgoMiKuPI,1820251
22
+ neo4j_viz/resources/nvl_entrypoint/styles.css,sha256=sRA-0i4Bc-P2S3FHg8FjTBiChr0ikC8f0UOYduXAXT0,1354
23
+ neo4j_viz-1.0.0.dist-info/licenses/LICENSE,sha256=tWSeLI0mRp2u8Pnumaxq51JltfXLVSXl2w_D6kxhRMI,36006
24
+ neo4j_viz-1.0.0.dist-info/METADATA,sha256=vDiI0KP0eUawlpabsGfhDVGea5mZwSSwOYvEmrpHlao,7141
25
+ neo4j_viz-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ neo4j_viz-1.0.0.dist-info/top_level.txt,sha256=jPUM3z8MOtxqDanc2VzqkxG4HJn8aaq4S7rnCFNk_Vs,10
27
+ neo4j_viz-1.0.0.dist-info/RECORD,,