graph_widget 0.1.11__tar.gz → 0.1.12__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.
- {graph_widget-0.1.11 → graph_widget-0.1.12}/PKG-INFO +1 -1
- {graph_widget-0.1.11 → graph_widget-0.1.12}/example_2.py +7 -5
- {graph_widget-0.1.11 → graph_widget-0.1.12}/pyproject.toml +1 -1
- {graph_widget-0.1.11 → graph_widget-0.1.12}/src/graph_widget/__init__.py +2 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/src/graph_widget/static/widget.js +13 -9
- {graph_widget-0.1.11 → graph_widget-0.1.12}/uv.lock +1 -1
- {graph_widget-0.1.11 → graph_widget-0.1.12}/.gitignore +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/.python-version +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/README.md +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/README_DEV.md +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/bug_test.py +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/data.json +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/dev.py +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/graph_3d_example.py +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/multi_mst.json +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/src/graph_widget/dev.py +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/src/graph_widget/static/widget.css +0 -0
- {graph_widget-0.1.11 → graph_widget-0.1.12}/vis-forge-marimo.py +0 -0
|
@@ -60,7 +60,9 @@ def _(data, graph_widget, mo):
|
|
|
60
60
|
repulsion=2,
|
|
61
61
|
node_scale=2,
|
|
62
62
|
colour_feature="",
|
|
63
|
-
colour_scale_type=""
|
|
63
|
+
colour_scale_type="",
|
|
64
|
+
height=200,
|
|
65
|
+
width=600
|
|
64
66
|
)
|
|
65
67
|
)
|
|
66
68
|
return (data_graph,)
|
|
@@ -74,10 +76,10 @@ def _(
|
|
|
74
76
|
node_scale_slider,
|
|
75
77
|
repulsion_slider,
|
|
76
78
|
):
|
|
77
|
-
data_graph.repulsion = repulsion_slider.value
|
|
78
|
-
data_graph.node_scale = node_scale_slider.value
|
|
79
|
-
data_graph.colour_feature = colour_feature_dropdown.value
|
|
80
|
-
data_graph.colour_scale_type= colour_scale_type_radio.value
|
|
79
|
+
data_graph.widget.repulsion = repulsion_slider.value
|
|
80
|
+
data_graph.widget.node_scale = node_scale_slider.value
|
|
81
|
+
data_graph.widget.colour_feature = colour_feature_dropdown.value
|
|
82
|
+
data_graph.widget.colour_scale_type= colour_scale_type_radio.value
|
|
81
83
|
return
|
|
82
84
|
|
|
83
85
|
|
|
@@ -20,3 +20,5 @@ class ForceGraphWidget(anywidget.AnyWidget):
|
|
|
20
20
|
colour_feature = traitlets.Unicode().tag(sync=True)
|
|
21
21
|
colour_scale_type = traitlets.Unicode().tag(sync=True)
|
|
22
22
|
selected_ids = traitlets.List([]).tag(sync=True)
|
|
23
|
+
width = traitlets.Int().tag(sync=True)
|
|
24
|
+
height = traitlets.Int().tag(sync=True)
|
|
@@ -7,8 +7,8 @@ import { scaleLinear, scaleOrdinal, scaleIdentity } from "https://esm.sh/d3-scal
|
|
|
7
7
|
import { schemeCategory10 } from "https://esm.sh/d3-scale-chromatic";
|
|
8
8
|
import RBush from 'https://cdn.jsdelivr.net/npm/rbush/+esm';
|
|
9
9
|
|
|
10
|
-
let
|
|
11
|
-
let
|
|
10
|
+
let default_width = 800;
|
|
11
|
+
let default_height = 500;
|
|
12
12
|
|
|
13
13
|
class MyRBush extends RBush {
|
|
14
14
|
toBBox(node) { return { id: node.id, minX: node.x, minY: node.y, maxX: node.x, maxY: node.y }; }
|
|
@@ -17,7 +17,8 @@ class MyRBush extends RBush {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
let local_selected_ids = []
|
|
20
|
-
let
|
|
20
|
+
let default_repulsion = 1;
|
|
21
|
+
let default_node_scale = 1;
|
|
21
22
|
let node_scale = 1;
|
|
22
23
|
let colour_scale_type = "";
|
|
23
24
|
let plot;
|
|
@@ -54,7 +55,7 @@ const isLinux = ua.includes('linux');
|
|
|
54
55
|
function render({ model, el }) {
|
|
55
56
|
const debouncedSaveChanges = debounce(() => model.save_changes(), 300);
|
|
56
57
|
|
|
57
|
-
const create_plot = (
|
|
58
|
+
const create_plot = (data) => {
|
|
58
59
|
return ForceGraph()(el)
|
|
59
60
|
.width(width)
|
|
60
61
|
.height(height)
|
|
@@ -72,13 +73,15 @@ function render({ model, el }) {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
const data = model.get("data");
|
|
75
|
-
repulsion = model.get("repulsion");
|
|
76
|
-
node_size = model.get("node_scale");
|
|
76
|
+
let repulsion = model.get("repulsion") || default_repulsion;
|
|
77
|
+
let node_size = model.get("node_scale") || default_node_scale;
|
|
78
|
+
let width = model.get("width") || default_width;
|
|
79
|
+
let height = model.get("height") || default_height;
|
|
77
80
|
colour_scale_type = model.get("colour_scale_type");
|
|
78
81
|
colour_feature = model.get("colour_feature");
|
|
79
82
|
let global_selected_ids = model.get("selected_ids")
|
|
80
83
|
|
|
81
|
-
plot = create_plot(
|
|
84
|
+
plot = create_plot(data);
|
|
82
85
|
model.on("change:repulsion", () => {
|
|
83
86
|
repulsion = model.get("repulsion");
|
|
84
87
|
plot.d3Force('charge', forceManyBody().strength(-repulsion));
|
|
@@ -287,9 +290,10 @@ function render({ model, el }) {
|
|
|
287
290
|
let my_brush = brush()
|
|
288
291
|
.filter((event) => {
|
|
289
292
|
const modifierKey = isMac ? event.metaKey : event.ctrlKey;
|
|
293
|
+
console.log(modifierKey, event.button, event.target.__data__.type, event);
|
|
290
294
|
return (
|
|
291
|
-
|
|
292
|
-
(modifierKey || event.target.__data__.type
|
|
295
|
+
event.button == 0 && // Ignore mouse buttons other than left-click
|
|
296
|
+
(modifierKey || ["selection", "s", "e", "n", "w"].includes(event.target.__data__.type))
|
|
293
297
|
)
|
|
294
298
|
})
|
|
295
299
|
.extent([[0, 0], [width, height]])
|
|
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
|