Skip to main content

Draw.io Diagrams as Jupyter Widgets

Project description

IPyDrawio

demo docs install build
binder-badge docs install from pypi install from conda-forge reuse from npm build coverage

Drawio diagrams for JupyterLab. Forked with ❤️ from QuantStack/jupyterlab-drawio.

Install · History · Roadmap · Contribute · Open Source

This is BETA software. Native drawio files created with these tools should work with any other drawio client, but any UI/API is liable to change at any time.

Installation

mamba install -c conda-forge ipydrawio  # recommended, or...
conda install -c conda-forge ipydrawio  # or...
pip install ipydrawio[all]

Features

  • ipydrawio
    • full support for JupyterLab
    • best-effort support for JupyterLiteⓁ and RetroLabⓡ
    • Edit multi-page documents
      • with nearly the same UI and features as diagrams.net
      • in many file formats
        • Drawio/mxgraph XML, SVG, PNG
        • or Jupyter Notebooksⓡ
      • with all the Drawio templatesⓡ
        • plus some Jupyter ones
    • Jupyter rich display output
    • Jupyter Widgets
    • Basic collaborative editing
      • requires the --collaborative flag, added in JupyterLab 3.1+
      • token sharing, a la jupyterlab-link-share, or a custom connector (no known yet)
      • no presence indicators for other editors
  • ipydrawio-export
    • Export print-quality PDF from diagramsⓁⓡ
      • optionally include editable Drawio XML as a PDF attachment
      • BEWARE: some heavy, maybe fragile dependencies, mamba recommended

        mamba install -c conda-forge ipydrawio-export  # recommended, or...
        conda install -c conda-forge ipydrawio-export  # or...
        pip install ipydrawio ipydrawio-export
        

ⓡ: unavailable in RetroLab Ⓛ: unavailable in JupyterLite

Examples

Note Screenshot/Example
Screenshot of drawio "minimal" UI with export options poster-min
The beginning of an interactive computational poster poster
A mixed computational/creative roadmap for this project Screenshot Needed

Usage

Please see the docs for full information

  • Try on binder-badge
  • Open a diagram, by doing one of:
    • Creating a Diagram_ from the Launcher
    • Uploading a diagram created on diagrams.net with the File Manager and double clicking it
    • Building diagrams by interactively computing in IPython with ipydrawio.Diagram
    • Use the application/x-drawio MIME renderer
  • Use the Command Palette to Export Diagram to various formats
    • NOTE: some of the built-in UI features of drawio don't work properly inside an IFrame in JupyterLab, and are difficult to robustly disable: please see Diagram options available in the Command Palette and various Main Menu menus.

Configuring

UI Themes

Your default theme can be changed in the JupyterLab Main Menu:

  • open Settings
  • open Diagram Theme
  • select your theme
  • all open documents will change to this theme (prompting if not saved)
  • all future documents will use this theme

The different themes have some advantages and disadvantages:

theme default full menu layers pages light dark rough
atlas ✔️ ✔️ ✔️ ✔️
dark ✔️ ✔️ ✔️ ✔️
kennedy ✔️ ✔️ ✔️ ✔️
min ✔️ ✔️ ✔️ ✔️ ⚙️
sketch ✔️ ✔️ ⚙️ ✔️

Note that rough will change how many shapes look

Drawio Configuration and URL parameters

Use Advanced Settings to modify drawio embedding parameters

See the schema for full details of the (known) supported options as well as the upstream docs for all parameters, though IPyDrawio might not support them... yet.

PDF: Lab and Server extensions

ipydrawio-export can generate print-quality PDF. This approach relies on a headless browser, powered by @jgraph/draw-image-export2, puppeteer, and nodejs.

  • native dependencies as required to appease puppeteer
    • if running in docker, this can be a bit trial-and-error
    • for more, see the binder and CI.
  • nodejs>10,<14 from conda or your system package manager
    • NOTE: this relies on being able to install puppeteer (and other arbitrary dependencies with jlpm for now when first used
      • we'll figure out a better approach soon enough
  • pip install ipydrawio-export or conda install -c conda-forge ipydrawio-export

For example to install all the dependencies:

conda install -yc conda-forge ipydrawio-export

Once installed, you can use the in-browser tools Export Diagram as PDF as well as the command line:

jupyter ipydrawio-export <name of document>

Open Source

License

All files herein, unless otherwise noted, are free software licensed under Apache 2.0.

Copyright

The copyright holders of this extension are the contributors to this repository.

Portions of the JupyterLab components are derived from QuantStack/jupyterlab-drawio.

The copyright holders of drawio and drawio-export is jgraph.

The original source code vendored in this package from:

Copyright 2021 ipydrawio contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Download files

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

Source Distribution

ipydrawio-1.1.3.tar.gz (33.6 MB view details)

Uploaded Source

Built Distribution

ipydrawio-1.1.3-py3-none-any.whl (72.4 MB view details)

Uploaded Python 3

File details

Details for the file ipydrawio-1.1.3.tar.gz.

File metadata

  • Download URL: ipydrawio-1.1.3.tar.gz
  • Upload date:
  • Size: 33.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ipydrawio-1.1.3.tar.gz
Algorithm Hash digest
SHA256 0a29e805a064ddc0bd8deead240ce4d523e6e33602c4f620fd8f9ed00994234b
MD5 ba8e2db60d10f74acf22eb420b154cdd
BLAKE2b-256 97dda471b814d95615233a85ecbeae91a796748e997fe334f6027bc111666fda

See more details on using hashes here.

Provenance

File details

Details for the file ipydrawio-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: ipydrawio-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 72.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ipydrawio-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2b899f4c12bbd881ef3029d6965ee4cfc71c80ed1fe6e1684cd881b01000cc4e
MD5 9d33a084004a618c65ec7e7610c1179f
BLAKE2b-256 f0c32334341106dddec676a8da4869004d6c1b9171eba436348655907a362dcc

See more details on using hashes here.

Provenance

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