d3graph 2.9.5__tar.gz → 3.0.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d3graph
3
- Version: 2.9.5
3
+ Version: 3.0.0
4
4
  Summary: Python package to create interactive network based on d3js.
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -105,8 +105,8 @@ from d3graph import d3graph
105
105
 
106
106
 
107
107
  <p align="left">
108
- <a href="https://erdogant.github.io/docs/d3graph/titanic_example/index.html">
109
- <img src="https://github.com/d3blocks/d3blocks/blob/main/docs/figs/d3graph/socialmedia.gif" width="1000"/>
108
+ <a href="http://erdogant.github.io/docs/d3graph/d3graph/socialmedia.html">
109
+ <img src="http://erdogant.github.io/docs/d3graph/d3graph/socialmedia.gif" width="1000"/>
110
110
  </a>
111
111
  </p>
112
112
 
@@ -74,8 +74,8 @@ from d3graph import d3graph
74
74
 
75
75
 
76
76
  <p align="left">
77
- <a href="https://erdogant.github.io/docs/d3graph/titanic_example/index.html">
78
- <img src="https://github.com/d3blocks/d3blocks/blob/main/docs/figs/d3graph/socialmedia.gif" width="1000"/>
77
+ <a href="http://erdogant.github.io/docs/d3graph/d3graph/socialmedia.html">
78
+ <img src="http://erdogant.github.io/docs/d3graph/d3graph/socialmedia.gif" width="1000"/>
79
79
  </a>
80
80
  </p>
81
81
 
@@ -17,7 +17,7 @@ from d3graph.d3graph import (
17
17
 
18
18
  __author__ = 'Erdogan Tasksen'
19
19
  __email__ = 'erdogant@gmail.com'
20
- __version__ = '2.9.5'
20
+ __version__ = '3.0.0'
21
21
 
22
22
  # Setup root logger
23
23
  _logger = logging.getLogger('d3graph')
@@ -65,9 +65,9 @@ class d3graph:
65
65
  def __init__(self,
66
66
  collision: float = 0.5,
67
67
  charge: int = 600,
68
+ link_tension: float = 1,
68
69
  slider=None,
69
70
  support: str = 'text',
70
- link_tension: float = 1,
71
71
  sticky: bool = True,
72
72
  verbose: int = 20) -> None:
73
73
  """Initialize d3graph.
@@ -106,7 +106,7 @@ class d3graph:
106
106
  if clean_config and hasattr(self, 'config'): del self.config
107
107
 
108
108
  def show(self,
109
- figsize=[1500, 800],
109
+ figsize=[None, None],
110
110
  title: str = 'd3graph',
111
111
  filepath: str = None,
112
112
  showfig: bool = True,
@@ -115,7 +115,7 @@ class d3graph:
115
115
  set_slider: bool = 0,
116
116
  click={'fill': None, 'stroke': 'black', 'size': 1.3, 'stroke-width': 3},
117
117
  background_color = '#FFFFFF',
118
- dark_mode = False,
118
+ dark_mode = True,
119
119
  notebook: bool = False,
120
120
  save_button: bool = True,
121
121
  link_tension: float = None,
@@ -126,15 +126,16 @@ class d3graph:
126
126
  canvas_edge_threshold: int = 2000,
127
127
  show_density: bool = False,
128
128
  density_grid_size: int = 60,
129
- density_blur: int = 10,
130
- density_opacity: float = 0.6,
129
+ density_blur: int = 15,
130
+ density_opacity: float = 0.8,
131
131
  show_controls: bool = True,
132
+ highlight_full_network: bool = True,
132
133
  ) -> None:
133
134
  """Build and show the graph.
134
135
 
135
136
  Parameters
136
137
  ----------
137
- figsize : tuple, (default: (1500, 800))
138
+ figsize : tuple, (default: (None, None))
138
139
  Size of the figure in the browser, (width, height).
139
140
  (None, None): Use the screen resolution.
140
141
  title : String, (default: None)
@@ -216,6 +217,13 @@ class d3graph:
216
217
  just hidden, so there's no extra DOM/clutter in the embed. The weight/component
217
218
  sliders are controlled separately via show_slider; the Save button specifically
218
219
  is also controlled via save_button, independent of this.
220
+ highlight_full_network : bool, (default: True)
221
+ Controls how much of the graph lights up when a node is clicked.
222
+ True: The entire connected network reachable from the clicked node (every node
223
+ and edge in its connected component, not just its direct neighbors) is
224
+ highlighted; everything outside that component is dimmed.
225
+ False: Only the clicked node's directly-connected neighbors/edges (one hop)
226
+ are highlighted, matching the old default behavior.
219
227
 
220
228
  Returns
221
229
  -------
@@ -246,6 +254,7 @@ class d3graph:
246
254
  self.config['density_blur'] = density_blur
247
255
  self.config['density_opacity'] = density_opacity
248
256
  self.config['show_controls'] = show_controls
257
+ self.config['highlight_full_network'] = highlight_full_network
249
258
 
250
259
  # Allow show() to override the link_tension set at __init__ time
251
260
  if link_tension is not None:
@@ -848,8 +857,8 @@ class d3graph:
848
857
  # Hide slider
849
858
  show_slider = ['', ''] if self.config['show_slider'] else ['<!--', '-->']
850
859
  # Set width and height to screen resolution if None.
851
- width = 'window.screen.width' if self.config['figsize'][0] is None else self.config['figsize'][0]
852
- height = 'window.screen.height' if self.config['figsize'][1] is None else self.config['figsize'][1]
860
+ width = 'window.innerWidth' if self.config['figsize'][0] is None else self.config['figsize'][0]
861
+ height = 'null' if self.config['figsize'][1] is None else self.config['figsize'][1]
853
862
  # Get support
854
863
  support = self.config.get('support')
855
864
  if support is None: support = get_support('text')
@@ -874,6 +883,7 @@ class d3graph:
874
883
  'density_blur': self.config.get('density_blur', 8),
875
884
  'density_opacity': self.config.get('density_opacity', 0.6),
876
885
  'show_controls': self.config.get('show_controls', True),
886
+ 'highlight_full_network': self.config.get('highlight_full_network', True),
877
887
  'save_button': self.config['save_button'],
878
888
  'node_text_inside': self.config.get('node_text_inside', False),
879
889
  'CLICK_COMMENT': CLICK_COMMENT,
@@ -897,7 +907,6 @@ class d3graph:
897
907
  html = index_template.render(content)
898
908
 
899
909
  index_file = self.config['filepath']
900
- # index_file.write_text(index_template.render(content))
901
910
  if overwrite and index_file:
902
911
  logger.info(f'Write to path: [{index_file.absolute()}]')
903
912
  logger.info(f'File already exists and will be overwritten: [{index_file}]')