Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO Items #8

Open
nightvision04 opened this issue Apr 22, 2021 · 4 comments
Open

TODO Items #8

nightvision04 opened this issue Apr 22, 2021 · 4 comments

Comments

@nightvision04
Copy link

It would be very handy indeed if there was a simple CLI for code->svg.

Flowchart.js is javascript (obviously), so how would you feel if I made a pull request that installed npm, and the npm 'diagrams' package? From there, it's really just a simple CLI interface once those 2 things are installed.

@cdfmlr
Copy link
Owner

cdfmlr commented Apr 23, 2021

Thanks for your plan. Just feel free to begin your work with following things noticed:

  1. how to install the js environment in different platforms (Linux, macOS, Windows)
  2. npm & the needed package may be already installed. before install, detect it.

@psychemedia
Copy link

psychemedia commented Jun 14, 2021

Hi - I have a Jupyter demo that wraps flowchart.js as a Jupyter widget (there may be better ways of packaging things...) and uses IPython magic to render code in magicked cells:

https://github.com/innovationOUtside/flowchart_js_jp_proxy_widget/

Issues: innovationOUtside/flowchart_js_jp_proxy_widget#2

image

@cdfmlr
Copy link
Owner

cdfmlr commented Jun 16, 2021

Hi - I have a Jupyter demo that wraps flowchart.js as a Jupyter widget (there may be better ways of packaging things...) and uses IPython magic to render code in magicked cells:

https://github.com/innovationOUtside/flowchart_js_jp_proxy_widget/

Issues: innovationOUtside/flowchart_js_jp_proxy_widget#2

image

@psychemedia What a magic! A bit trouble to setup notwithstanding, it's useful.

Here is the detailed way to setup:

  1. install jp_proxy_widget
$ pip install jp_proxy_widget
$ jupyter nbextension install --py --symlink --sys-prefix jp_proxy_widget
$ jupyter nbextension enable --py --sys-prefix jp_proxy_widget
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager
$ jupyter labextension install jp_proxy_widget
  1. install jp_flowchartjs
$ pip install jp_flowchartjs
  1. install pyflowchart
pip install pyflowchart
  1. Run jupyter lab, open a notebook, and run this:
from jp_flowchartjs.jp_flowchartjs import *
from IPython.core.magic import register_cell_magic
from pyflowchart import Flowchart

@register_cell_magic
def flowchart_magic(line, cell):
    "Send code to simulator."
    return FlowchartWidget().charter(cell, embed=True)
    
    
@register_cell_magic
def pyflowchart_magic(line, cell):
    "Generate flowchart code and send to flow charter."
    fc = Flowchart.from_code(cell)
    return FlowchartWidget().charter(str(fc.flowchart()), embed=True)
  1. then, enjoy the magic:
%%flowchart_magic
st=>start: Start
e=>end: End
op1=>operation: Generate
op2=>parallel: Evaluate
st(right)->op1(right)->op2
op2(path1, top)->op1
op2(path2, right)->e

&

%%pyflowchart_magic 
import time

def demo(msg='demo'):
    for i in range(10):
        print(f'{msg} loopcount is {i}')
        time.sleep(i)

@psychemedia
Copy link

I just simplified the setup; now you should just need to install the package and in a notebook run %load_ext jp_flowchartjs to make the magics available. Thanks for the prompt:-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants