d3graph 2.8.1__tar.gz → 2.8.2__tar.gz
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.
- {d3graph-2.8.1/d3graph.egg-info → d3graph-2.8.2}/PKG-INFO +1 -1
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/__init__.py +1 -1
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/d3graph.py +10 -5
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/examples.py +25 -0
- {d3graph-2.8.1 → d3graph-2.8.2/d3graph.egg-info}/PKG-INFO +1 -1
- {d3graph-2.8.1 → d3graph-2.8.2}/LICENSE +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/MANIFEST.in +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/README.md +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/d3js/d3.v3.js +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/d3js/d3graphscript.js +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/d3js/index.html.j2 +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/d3js/style.css +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph/examples_docs.py +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph.egg-info/SOURCES.txt +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph.egg-info/dependency_links.txt +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph.egg-info/requires.txt +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/d3graph.egg-info/top_level.txt +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/pyproject.toml +0 -0
- {d3graph-2.8.1 → d3graph-2.8.2}/setup.cfg +0 -0
|
@@ -485,8 +485,10 @@ class d3graph:
|
|
|
485
485
|
node_names = self.adjmat.columns.astype(str)
|
|
486
486
|
nodecount = self.adjmat.shape[0]
|
|
487
487
|
group = np.zeros_like(node_names).astype(int)
|
|
488
|
+
|
|
488
489
|
# Check validity of color.
|
|
489
490
|
color = _check_hex_color(color, nodecount, cmap=cmap)
|
|
491
|
+
|
|
490
492
|
# Store in config
|
|
491
493
|
self.config['cmap'] = 'Paired' if cmap is None else cmap
|
|
492
494
|
self.config['node_scaler'] = scaler
|
|
@@ -1621,18 +1623,21 @@ def adjmat2vec(adjmat, min_weight: float = 1.0) -> pd.DataFrame:
|
|
|
1621
1623
|
def _check_hex_color(color, n=None, cmap='Set1'):
|
|
1622
1624
|
seq_types = (list, np.ndarray, pd.Series, StringArray)
|
|
1623
1625
|
|
|
1626
|
+
if isinstance(color, str) and color=='cluster':
|
|
1627
|
+
return 'cluster'
|
|
1628
|
+
|
|
1624
1629
|
# Single string
|
|
1625
1630
|
if isinstance(color, str):
|
|
1626
1631
|
if len(color) != 7 or not color.startswith('#'):
|
|
1627
|
-
logger.warning('Invalid [color] format. Expected "#000000" <auto-fixing>')
|
|
1628
|
-
return get_hex_color(color, cmap=cmap)[0]
|
|
1632
|
+
logger.warning('1. Invalid [color] format. Expected "#000000" <auto-fixing>')
|
|
1633
|
+
return get_hex_color([color]*n, cmap=cmap)[0]
|
|
1629
1634
|
return color
|
|
1630
1635
|
|
|
1631
1636
|
# Sequence input
|
|
1632
1637
|
if isinstance(color, seq_types):
|
|
1633
1638
|
|
|
1634
1639
|
if len(color) == 0:
|
|
1635
|
-
logger.warning('Invalid [color] sequence. Expected ["#000000", ...] <auto-fixing>')
|
|
1640
|
+
logger.warning('2. Invalid [color] sequence. Expected ["#000000", ...] <auto-fixing>')
|
|
1636
1641
|
return get_hex_color(color, cmap=cmap)[0]
|
|
1637
1642
|
|
|
1638
1643
|
valid = np.all([
|
|
@@ -1641,11 +1646,11 @@ def _check_hex_color(color, n=None, cmap='Set1'):
|
|
|
1641
1646
|
])
|
|
1642
1647
|
|
|
1643
1648
|
if not valid:
|
|
1644
|
-
logger.warning('Invalid hex colors in [color]. Expected ["#000000", ...] <auto-fixing>')
|
|
1649
|
+
logger.warning('3. Invalid hex colors in [color]. Expected ["#000000", ...] <auto-fixing>')
|
|
1645
1650
|
return get_hex_color(color, cmap=cmap)[0]
|
|
1646
1651
|
|
|
1647
1652
|
if (n is not None) and (len(color) != n):
|
|
1648
|
-
logger.warning(f'Invalid [color] length. Expected length={n} <auto-fixing>')
|
|
1653
|
+
logger.warning(f'4. Invalid [color] length. Expected length={n} <auto-fixing>')
|
|
1649
1654
|
return get_hex_color(color, cmap=cmap)[0]
|
|
1650
1655
|
|
|
1651
1656
|
return color
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# %% SET PATH ISSUE https://github.com/erdogant/d3graph/issues/42
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from d3graph import d3graph, vec2adjmat, import_example
|
|
4
|
+
output_path = Path.cwd() / 'd3graph.html'
|
|
5
|
+
|
|
6
|
+
# Load example data
|
|
7
|
+
df = import_example('stormofswords')
|
|
8
|
+
adjmat = vec2adjmat(source=df['source'], target=df['target'], weight=df['weight'])
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# sticky=True (default) — drag to pin, right-click to release
|
|
12
|
+
d3 = d3graph(sticky=True)
|
|
13
|
+
d3.set_path(output_path)
|
|
14
|
+
d3.config['filepath']
|
|
15
|
+
|
|
16
|
+
d3.graph(adjmat)
|
|
17
|
+
d3.show()
|
|
18
|
+
|
|
19
|
+
# sticky=False — classic spring-back behaviour
|
|
20
|
+
d3 = d3graph(adjmat, sticky=False)
|
|
21
|
+
d3.show()
|
|
22
|
+
|
|
23
|
+
# %%
|
|
24
|
+
|
|
25
|
+
|
|
1
26
|
from d3graph import d3graph, import_example, vec2adjmat
|
|
2
27
|
|
|
3
28
|
d3 = d3graph()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|