graph_widget 0.1.7__tar.gz → 0.1.9__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.7 → graph_widget-0.1.9}/PKG-INFO +1 -1
- {graph_widget-0.1.7 → graph_widget-0.1.9}/example_2.py +1 -1
- {graph_widget-0.1.7 → graph_widget-0.1.9}/pyproject.toml +1 -1
- {graph_widget-0.1.7 → graph_widget-0.1.9}/src/graph_widget/static/widget.js +60 -11
- {graph_widget-0.1.7 → graph_widget-0.1.9}/uv.lock +1 -1
- {graph_widget-0.1.7 → graph_widget-0.1.9}/.gitignore +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/.python-version +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/README.md +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/README_DEV.md +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/bug_test.py +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/data.json +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/dev.py +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/multi_mst.json +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/src/graph_widget/__init__.py +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/src/graph_widget/dev.py +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/src/graph_widget/static/widget.css +0 -0
- {graph_widget-0.1.7 → graph_widget-0.1.9}/vis-forge-marimo.py +0 -0
|
@@ -41,7 +41,7 @@ def _(data, mo):
|
|
|
41
41
|
start=1, stop=20, step=1, value=3, debounce=True, label="Node scale"
|
|
42
42
|
)
|
|
43
43
|
colour_feature_dropdown = mo.ui.dropdown(
|
|
44
|
-
options=list(data["nodes"][3].keys()),
|
|
44
|
+
options=list(data["nodes"][3].keys()), label="Colour by"
|
|
45
45
|
)
|
|
46
46
|
colour_scale_type_radio = mo.ui.radio(options=["diverging", "sequential"], value="diverging", label="Colour scale type")
|
|
47
47
|
return (
|
|
@@ -126,6 +126,10 @@ function render({ model, el }) {
|
|
|
126
126
|
ctx.lineWidth = radius/5;
|
|
127
127
|
ctx.strokeStyle = 'red';
|
|
128
128
|
ctx.stroke();
|
|
129
|
+
} else {
|
|
130
|
+
ctx.lineWidth = 1;
|
|
131
|
+
ctx.strokeStyle = 'white';
|
|
132
|
+
ctx.stroke();
|
|
129
133
|
}
|
|
130
134
|
});
|
|
131
135
|
|
|
@@ -147,21 +151,66 @@ function render({ model, el }) {
|
|
|
147
151
|
let feature_type = get_feature_type(feature_values[0])
|
|
148
152
|
if ( feature_type == "numeric" ) {
|
|
149
153
|
if ( colour_scale_type == "diverging" ) {
|
|
150
|
-
colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#
|
|
154
|
+
colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#0000FFBF","white","#FF0000BF"])
|
|
151
155
|
} else {
|
|
152
156
|
colour_scale = scaleLinear().domain(extent(feature_values)).range(["#FFFF0080", "#0000FF80"])
|
|
153
157
|
}
|
|
158
|
+
} else if ( feature_type == "categorical" ) {
|
|
159
|
+
colour_scale = scaleOrdinal().domain(extent(feature_values)).range(schemeCategory10)
|
|
160
|
+
} else if ( feature_type == "hash_string" ) {
|
|
161
|
+
colour_scale = scaleIdentity()
|
|
162
|
+
} else {
|
|
163
|
+
colour_scale = () => "#4682B480"; // Default colour
|
|
154
164
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
|
|
166
|
+
if (colour_scale_type === "diverging") {
|
|
167
|
+
// Sort nodes by absolute distance from zero
|
|
168
|
+
data.nodes.sort((a, b) => {
|
|
169
|
+
const aVal = Math.abs(a[colour_feature]);
|
|
170
|
+
const bVal = Math.abs(b[colour_feature]);
|
|
171
|
+
return aVal - bVal;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
plot.nodeCanvasObject((node, ctx) => {
|
|
176
|
+
const radius = node_size * node_scale;
|
|
177
|
+
const isLocalSelected = local_selected_ids.includes(node.id);
|
|
178
|
+
const fillColour = colour_scale(node[colour_feature]);
|
|
179
|
+
|
|
180
|
+
// Draw filled circle
|
|
181
|
+
ctx.beginPath();
|
|
182
|
+
ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false);
|
|
183
|
+
ctx.fillStyle = fillColour;
|
|
184
|
+
ctx.fill();
|
|
185
|
+
|
|
186
|
+
// Draw red stroke if node is locally selected
|
|
187
|
+
if (isLocalSelected) {
|
|
188
|
+
ctx.lineWidth = radius/5;
|
|
189
|
+
ctx.strokeStyle = 'red';
|
|
190
|
+
ctx.stroke();
|
|
191
|
+
} else {
|
|
192
|
+
ctx.lineWidth = 1;
|
|
193
|
+
ctx.strokeStyle = 'lightgrey';
|
|
194
|
+
ctx.stroke();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
// if ( feature_type == "numeric" ) {
|
|
198
|
+
// if ( colour_scale_type == "diverging" ) {
|
|
199
|
+
// colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#0000FF80","#EEEEEE80","#FF000080"])
|
|
200
|
+
// } else {
|
|
201
|
+
// colour_scale = scaleLinear().domain(extent(feature_values)).range(["#FFFF0080", "#0000FF80"])
|
|
202
|
+
// }
|
|
203
|
+
// }
|
|
204
|
+
// plot.nodeColor((d) => {
|
|
205
|
+
// return global_selected_ids.includes(d.id)
|
|
206
|
+
// ? "yellow"
|
|
207
|
+
// : local_selected_ids.includes(d.id)
|
|
208
|
+
// ? "rgba(255,0,0,0.5)" // Red for local_selected_ids nodes
|
|
209
|
+
// : feature_type === undefined
|
|
210
|
+
// ? "#4682B480" // Default colour
|
|
211
|
+
// : feature_type === 'hash_string'
|
|
212
|
+
// ? d[colour_feature] // Use the hash string directly
|
|
213
|
+
// : colour_scale(d[colour_feature])})
|
|
165
214
|
})
|
|
166
215
|
model.on("change:selected_ids", () => {
|
|
167
216
|
global_selected_ids = model.get("selected_ids");
|
|
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
|