Skip to main content

A Streamlit custom component for Cytoscape.js

Project description

Streamlit Cytoscape.js

Streamlit wrapper of React Cytoscape.js.

Installation

pip install streamlit-cytoscapejs

Try it

import streamlit as st
from streamlit_cytoscapejs import st_cytoscapejs

elements = [
    {"data": {"id": "one", "label": "Node 1"}, "position": {"x": 0, "y": 0}},
    {"data": {"id": "two", "label": "Node 2"}, "position": {"x": 100, "y": 0}},
    {"data": {"source": "one", "target": "two", "label": "Edge from Node1 to Node2"}},
]
stylesheet = [
    {"selector": "node", "style": {"width": 20, "height": 20, "shape": "rectangle"}},
    {"selector": "edge", "style": {"width": 10}},
]

st.title("Hello Cytoscape.js")
st_cytoscapejs(elements, stylesheet)

Development

Install

  • JS side
cd streamlit_cytoscape/frontend
npm install
  • Python side
conda create -n streamlit-cytoscapejs python=3.7
conda activate streamlit-cytoscapejs
pip install -e .

Run

Both webpack dev server and Streamlit should run at the same time.

  • JS side
cd streamlit_cytoscape/frontend
npm run start
  • Python side
streamlit run app.py

Next steps

I don't plan to make a lot of progress on this for now (except if huge interest) but if you want to contribute/take over its development I'm happy to lend a hand :).

Obviously missing lots of things like:

  • viewport manipulation props from React cytoscapejs.
  • custom layout
  • adding an extension (but also you'd better fork this repo and add the extension yourself I think :/)

References

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

streamlit-cytoscapejs-0.0.1.tar.gz (1.0 MB view hashes)

Uploaded Source

Built Distribution

streamlit_cytoscapejs-0.0.1-py3-none-any.whl (1.1 MB view hashes)

Uploaded Python 3

Supported by

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