Skip to main content

Python object for dash-cytoscape elements

Project description

dash-cytoscape-elements

test PyPI - Python Version PyPI GitHub

This is a Python object for Dash Cytoscape Elements.

Features

  • Add/Remove/Get/Filter Element(Node/Edge) on Python object.
  • Convert Python object from/to Dash Cytoscape format
  • Convert Python object from/to json(Cytoscape.js format)

Install

pip install dash-cytoscape-elements

Usage

Example1: Create Elements object & using on Dash Cytoscape

import dash
import dash_cytoscape as cyto
from dash import html
from dash_cytoscape_elements import Elements

elements = Elements()
elements.add(id="one", label="Node 1", x=50, y=50)
elements.add(id="two", label="Node 2", x=200, y=200)
elements.add(source="one", target="two", label="Node 1 to 2")

app = dash.Dash(__name__)
app.layout = html.Div([
    cyto.Cytoscape(
        id='cytoscape',
        elements=elements.to_dash(),
        layout={'name': 'preset'}
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Example2: Edit json file of Elements.

from dash_cytoscape_elements import Elements

e = Elements.from_file("elements.json")
e.remove(id="node2")
e.remove(source="node1", target="node2")

with open("elements.json", mode='w') as f:
    f.write(e.to_json())

Please see the Documentation for details.

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

dash-cytoscape-elements-0.0.1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

dash_cytoscape_elements-0.0.1-py3-none-any.whl (6.3 kB 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