Skip to main content

No project description provided

Project description

graph_widget

An anywidget implementation of force-graph (https://github.com/vasturiano/force-graph). It includes a brush (Cmd-drag).

Installation

pip install graph_widget

or with uv:

uv add graph_widget

Example

An example marimo script (available as example.py => run with uv run marimo edit example.py):

import graph_widget
import pandas as pd
import json
import requests

url = "https://raw.githubusercontent.com/observablehq/sample-datasets/refs/heads/main/miserables.json"
response = requests.get(url)
data = response.json()

repulsion_slider = mo.ui.slider(
    start=-100, stop=500, step=10, value=1, debounce=False, label="Repulsion"
)
node_scale_slider = mo.ui.slider(
    start=1, stop=20, step=1, value=3, debounce=True, label="Node scale"
)
colour_feature_dropdown = mo.ui.dropdown(
    options=list(data["nodes"][3].keys()), value="kind", label="Colour by"
)
colour_scale_type_radio = mo.ui.radio(options=["diverging", "sequential"], value="diverging", label="Colour scale type")

data_graph = mo.ui.anywidget(
    graph_widget.ForceGraphWidget(
        data=data,
        repulsion=2,
        node_scale=2,
        colour_feature="",
        colour_scale_type=""
    )
)

data_graph.repulsion = repulsion_slider.value
data_graph.node_scale = node_scale_slider.value
data_graph.colour_feature = colour_feature_dropdown.value
data_graph.colour_scale_type= colour_scale_type_radio.value

mo.hstack([data_graph,
    mo.vstack([
        repulsion_slider,
        node_scale_slider,
        colour_feature_dropdown,
        colour_scale_type_radio])], justify="start")

selected = data_graph.selected_ids

Arguments

  • repulsion
  • node_scale
  • colour_feature
  • colour_scale_type: can be empty string, or "diverging"

Development

We recommend using uv for development. It will automatically manage virtual environments and dependencies for you.

uv run marimo edit example.py

Changes made in src/graph_widget/static/ will be reflected in the notebook.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph_widget-0.1.8.tar.gz (178.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_widget-0.1.8-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file graph_widget-0.1.8.tar.gz.

File metadata

  • Download URL: graph_widget-0.1.8.tar.gz
  • Upload date:
  • Size: 178.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for graph_widget-0.1.8.tar.gz
Algorithm Hash digest
SHA256 78518703e9dc065e00c5306d6a405ba93c128e225d732e179bcb0cdcdf1fc5ce
MD5 4a0e0f2afaaff89ebcb833b61f62e9cb
BLAKE2b-256 b33e78b12fdfa49e8d936d20e7296ec4a63fcf3a5a91c872d88d0f516ee5321e

See more details on using hashes here.

File details

Details for the file graph_widget-0.1.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for graph_widget-0.1.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c81496e22861dc1e587c249e1cc3d423e2a1d017f1c525be0e9290f23c630976
MD5 18c243015d3427bf7aaaa441fc94cb5c
BLAKE2b-256 ca76d34fde6a72b5d14e9ae226d618ac27e5b721231e662d9e7897455313c58b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page