Code Monkey home page Code Monkey logo

streamlit-bd-cytoscapejs's Introduction

streamlit-bd-cytoscapejs

This package is a Streamlit bidrectional component that wraps the JavaScript library Cytoscape.js. It can draw networks (a.k.a. graphs) and its API is very similar to the JS package.

Installation

pip install -i https://test.pypi.org/simple/ streamlit-bd-cytoscapejs

Parameters

elements (dict): A dictionary specifing the nodes and edges that will be draw in the graph. It follows the Cytoscape.js standard.

stylesheet (dict): Dictionary specifing the style of the elements in the graph. Although this parameter is named style, the dictionary follows the Cytoscape.js standard of the style parameter.

layout (dict): A dictionary with the layout options. If not specified, it defaults to a grid.

key (str or None): An optional key that uniquely identifies this component. If this is None, and the component's arguments are changed, the component will be re-mounted in the Streamlit frontend and lose its current state.

Returns

object: The id of the element (node or edge) tapped.

Example

import streamlit as st
import numpy as np
import pandas as pd
import streamlit_bd_cytoscapejs

check = st.checkbox('Click here to choose a different graph')

if(check):
    elements = [
        {'data': {'id': 'a'}},
        {'data': {'id': 'b'}},
        {'data': {
            'id': 'ab',
            'source': 'a',
            'target': 'b'
        }}
    ]
    layout = {}
else:
    elements = [
        {'data': {'id': 'c'}},
        {'data': {'id': 'd'}},
        {'data': {
            'id': 'cd',
            'source': 'c',
            'target': 'd'
        }}
    ]
    layout = {'name': 'random'}

node_id = streamlit_bd_cytoscapejs.st_bd_cytoscape(
    elements,
    layout=layout,
    key='foo'
)
st.write(node_id)

streamlit-bd-cytoscapejs's People

Contributors

mateusccoelho avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

a-mckinley

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.