graph_widget 0.1.9__tar.gz → 0.1.11__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.9 → graph_widget-0.1.11}/PKG-INFO +1 -1
- graph_widget-0.1.11/graph_3d_example.py +59 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/pyproject.toml +1 -1
- {graph_widget-0.1.9 → graph_widget-0.1.11}/src/graph_widget/static/widget.js +12 -9
- {graph_widget-0.1.9 → graph_widget-0.1.11}/uv.lock +1 -1
- {graph_widget-0.1.9 → graph_widget-0.1.11}/.gitignore +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/.python-version +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/README.md +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/README_DEV.md +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/bug_test.py +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/data.json +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/dev.py +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/example_2.py +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/multi_mst.json +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/src/graph_widget/__init__.py +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/src/graph_widget/dev.py +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/src/graph_widget/static/widget.css +0 -0
- {graph_widget-0.1.9 → graph_widget-0.1.11}/vis-forge-marimo.py +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import marimo
|
|
2
|
+
|
|
3
|
+
__generated_with = "0.11.6"
|
|
4
|
+
app = marimo.App(width="full")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@app.cell
|
|
8
|
+
def _():
|
|
9
|
+
import anywidget
|
|
10
|
+
import traitlets
|
|
11
|
+
return anywidget, traitlets
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@app.cell
|
|
15
|
+
def _(anywidget, traitlets):
|
|
16
|
+
class CounterWidget(anywidget.AnyWidget):
|
|
17
|
+
_esm = """
|
|
18
|
+
import ForceGraph3D from "https://esm.sh/3d-force-graph";
|
|
19
|
+
const N = 300;
|
|
20
|
+
const gData = {
|
|
21
|
+
nodes: [...Array(N).keys()].map(i => ({ id: i })),
|
|
22
|
+
links: [...Array(N).keys()]
|
|
23
|
+
.filter(id => id)
|
|
24
|
+
.map(id => ({
|
|
25
|
+
source: id,
|
|
26
|
+
target: Math.round(Math.random() * (id-1))
|
|
27
|
+
}))
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function render({ model, el }) {
|
|
31
|
+
const create_plot = () => {
|
|
32
|
+
return ForceGraph3D()(el)
|
|
33
|
+
.graphData(gData)
|
|
34
|
+
}
|
|
35
|
+
create_plot()
|
|
36
|
+
}
|
|
37
|
+
export default { render };
|
|
38
|
+
"""
|
|
39
|
+
_css = """
|
|
40
|
+
.counter-widget button { color: white; font-size: 1.75rem; background-color: #ea580c; padding: 0.5rem 1rem; border: none; border-radius: 0.25rem; }
|
|
41
|
+
.counter-widget button:hover { background-color: #9a3412; }
|
|
42
|
+
"""
|
|
43
|
+
value = traitlets.Int(0).tag(sync=True)
|
|
44
|
+
return (CounterWidget,)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@app.cell
|
|
48
|
+
def _(CounterWidget):
|
|
49
|
+
CounterWidget()
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@app.cell
|
|
54
|
+
def _():
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
app.run()
|
|
@@ -45,6 +45,12 @@ const get_feature_type = (value) => {
|
|
|
45
45
|
return 'categorical'; // Default to categorical if not numeric or hash_string
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
49
|
+
|
|
50
|
+
const isMac = ua.includes('macintosh');
|
|
51
|
+
const isWindows = ua.includes('windows');
|
|
52
|
+
const isLinux = ua.includes('linux');
|
|
53
|
+
|
|
48
54
|
function render({ model, el }) {
|
|
49
55
|
const debouncedSaveChanges = debounce(() => model.save_changes(), 300);
|
|
50
56
|
|
|
@@ -89,7 +95,7 @@ function render({ model, el }) {
|
|
|
89
95
|
let feature_type = get_feature_type(feature_values[0])
|
|
90
96
|
if ( feature_type == "numeric" ) {
|
|
91
97
|
if ( colour_scale_type == "diverging" ) {
|
|
92
|
-
colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#0000FFBF","
|
|
98
|
+
colour_scale = scaleLinear().domain([min(feature_values), 0, max(feature_values)]).range(["#0000FFBF","white","#FF0000BF"])
|
|
93
99
|
} else {
|
|
94
100
|
colour_scale = scaleLinear().domain(extent(feature_values)).range(["#FFFF0080", "#0000FF80"])
|
|
95
101
|
}
|
|
@@ -127,8 +133,8 @@ function render({ model, el }) {
|
|
|
127
133
|
ctx.strokeStyle = 'red';
|
|
128
134
|
ctx.stroke();
|
|
129
135
|
} else {
|
|
130
|
-
ctx.lineWidth =
|
|
131
|
-
ctx.strokeStyle = '
|
|
136
|
+
ctx.lineWidth = radius/10;
|
|
137
|
+
ctx.strokeStyle = 'lightgrey';
|
|
132
138
|
ctx.stroke();
|
|
133
139
|
}
|
|
134
140
|
});
|
|
@@ -189,7 +195,7 @@ function render({ model, el }) {
|
|
|
189
195
|
ctx.strokeStyle = 'red';
|
|
190
196
|
ctx.stroke();
|
|
191
197
|
} else {
|
|
192
|
-
ctx.lineWidth =
|
|
198
|
+
ctx.lineWidth = radius/10;
|
|
193
199
|
ctx.strokeStyle = 'lightgrey';
|
|
194
200
|
ctx.stroke();
|
|
195
201
|
}
|
|
@@ -280,13 +286,10 @@ function render({ model, el }) {
|
|
|
280
286
|
|
|
281
287
|
let my_brush = brush()
|
|
282
288
|
.filter((event) => {
|
|
283
|
-
|
|
284
|
-
if (event.ctrlKey && event.button === 0) {
|
|
285
|
-
event.preventDefault();
|
|
286
|
-
}
|
|
289
|
+
const modifierKey = isMac ? event.metaKey : event.ctrlKey;
|
|
287
290
|
return (
|
|
288
291
|
!event.button && // Ignore mouse buttons other than left-click
|
|
289
|
-
(
|
|
292
|
+
(modifierKey || event.target.__data__.type !== "overlay")
|
|
290
293
|
)
|
|
291
294
|
})
|
|
292
295
|
.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
|
|
File without changes
|