graph_widget 0.1.4__tar.gz → 0.1.6__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.4 → graph_widget-0.1.6}/PKG-INFO +1 -1
- {graph_widget-0.1.4 → graph_widget-0.1.6}/pyproject.toml +1 -1
- {graph_widget-0.1.4 → graph_widget-0.1.6}/src/graph_widget/static/widget.js +48 -28
- {graph_widget-0.1.4 → graph_widget-0.1.6}/uv.lock +1 -1
- {graph_widget-0.1.4 → graph_widget-0.1.6}/.gitignore +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/.python-version +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/README.md +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/README_DEV.md +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/bug_test.py +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/data.json +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/dev.py +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/example_2.py +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/multi_mst.json +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/src/graph_widget/__init__.py +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/src/graph_widget/dev.py +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/src/graph_widget/static/widget.css +0 -0
- {graph_widget-0.1.4 → graph_widget-0.1.6}/vis-forge-marimo.py +0 -0
|
@@ -39,22 +39,6 @@ const create_rtree = (data) => {
|
|
|
39
39
|
tree.load(data)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function create_plot(el, width, height, data) {
|
|
43
|
-
return ForceGraph()(el)
|
|
44
|
-
.width(width)
|
|
45
|
-
.height(height)
|
|
46
|
-
.graphData(data)
|
|
47
|
-
// .d3Force('charge',forceManyBody().strength(-repulsion))
|
|
48
|
-
.cooldownTime(5000)
|
|
49
|
-
.warmupTicks(10)
|
|
50
|
-
.d3AlphaDecay(0.001)
|
|
51
|
-
.minZoom(0.001)
|
|
52
|
-
.onEngineStop(() => {
|
|
53
|
-
plot.zoomToFit(400);
|
|
54
|
-
create_rtree(data["nodes"]);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
42
|
const get_feature_type = (value) => {
|
|
59
43
|
if (typeof value === 'number') return 'numeric'; // Check for numeric
|
|
60
44
|
if (typeof value === 'string' && value.startsWith('#')) return 'hash_string'; // Check for strings starting with #
|
|
@@ -64,6 +48,23 @@ const get_feature_type = (value) => {
|
|
|
64
48
|
function render({ model, el }) {
|
|
65
49
|
const debouncedSaveChanges = debounce(() => model.save_changes(), 300);
|
|
66
50
|
|
|
51
|
+
const create_plot = (width, height, data) => {
|
|
52
|
+
return ForceGraph()(el)
|
|
53
|
+
.width(width)
|
|
54
|
+
.height(height)
|
|
55
|
+
.graphData(data)
|
|
56
|
+
// .d3Force('charge',forceManyBody().strength(-repulsion))
|
|
57
|
+
.cooldownTime(5000)
|
|
58
|
+
.warmupTicks(10)
|
|
59
|
+
.d3AlphaDecay(0.001)
|
|
60
|
+
.minZoom(0.001)
|
|
61
|
+
.nodeCanvasObjectMode(() => 'replace')
|
|
62
|
+
.onEngineStop(() => {
|
|
63
|
+
plot.zoomToFit(400);
|
|
64
|
+
create_rtree(data["nodes"]);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
67
68
|
const data = model.get("data");
|
|
68
69
|
repulsion = model.get("repulsion");
|
|
69
70
|
node_size = model.get("node_scale");
|
|
@@ -71,7 +72,7 @@ function render({ model, el }) {
|
|
|
71
72
|
colour_feature = model.get("colour_feature");
|
|
72
73
|
let global_selected_ids = model.get("selected_ids")
|
|
73
74
|
|
|
74
|
-
plot = create_plot(
|
|
75
|
+
plot = create_plot(width, height, data);
|
|
75
76
|
model.on("change:repulsion", () => {
|
|
76
77
|
repulsion = model.get("repulsion");
|
|
77
78
|
plot.d3Force('charge', forceManyBody().strength(-repulsion));
|
|
@@ -88,7 +89,7 @@ function render({ model, el }) {
|
|
|
88
89
|
let feature_type = get_feature_type(feature_values[0])
|
|
89
90
|
if ( feature_type == "numeric" ) {
|
|
90
91
|
if ( colour_scale_type == "diverging" ) {
|
|
91
|
-
colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#
|
|
92
|
+
colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#0000FFBF","#EEEEEE33","#FF0000BF"])
|
|
92
93
|
} else {
|
|
93
94
|
colour_scale = scaleLinear().domain(extent(feature_values)).range(["#FFFF0080", "#0000FF80"])
|
|
94
95
|
}
|
|
@@ -100,16 +101,35 @@ function render({ model, el }) {
|
|
|
100
101
|
colour_scale = undefined
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
plot.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
plot.nodeCanvasObject((node, ctx) => {
|
|
105
|
+
const radius = node_size * node_scale;
|
|
106
|
+
const isLocalSelected = local_selected_ids.includes(node.id);
|
|
107
|
+
const fillColour = colour_scale(node[colour_feature]);
|
|
108
|
+
|
|
109
|
+
// Draw filled circle
|
|
110
|
+
ctx.beginPath();
|
|
111
|
+
ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false);
|
|
112
|
+
ctx.fillStyle = fillColour;
|
|
113
|
+
ctx.fill();
|
|
114
|
+
|
|
115
|
+
// Draw red stroke if node is locally selected
|
|
116
|
+
if (isLocalSelected) {
|
|
117
|
+
ctx.lineWidth = radius/5;
|
|
118
|
+
ctx.strokeStyle = 'red';
|
|
119
|
+
ctx.stroke();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// plot.nodeColor((d) => {
|
|
124
|
+
// return global_selected_ids.includes(d.id)
|
|
125
|
+
// ? "yellow"
|
|
126
|
+
// : local_selected_ids.includes(d.id)
|
|
127
|
+
// ? "rgba(255,0,0,0.5)" // Red for local_selected_ids nodes
|
|
128
|
+
// : feature_type === undefined
|
|
129
|
+
// ? "#4682B480" // Default colour
|
|
130
|
+
// : feature_type === 'hash_string'
|
|
131
|
+
// ? d[colour_feature] // Use the hash string directly
|
|
132
|
+
// : colour_scale(d[colour_feature])})
|
|
113
133
|
});
|
|
114
134
|
model.on("change:colour_scale_type", () => {
|
|
115
135
|
colour_feature = model.get("colour_feature");
|
|
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
|