Skip to main content

A Python package for dashboard and data visualization tools.

Project description

DashLab

Binder PyPI version Downloads

An enhanced dashboarding library based on ipywidgets' interaction functionality that lets you observe any trait of widgets, observe multiple functions and build beautiful dashboards which can be turned into full screen.

Installation

You can install dashlab using pip:

pip install dashlab

Or if you prefer to install from source, clone the repository and in its top folder, run:

pip install -e .

Interactive Playground

✨ Try it in your browser ✨

Jupyter Lab Notebook Binder
Binder

Features

  • DashboardBase: Create interactive dashboard applications with minimal code by extending the dashlab.DashboardBase class and defining methods with the @callback decorator.
  • Dashboard: A ready-to-use dashboard class that allows quick setup of interactive dashboards without subclassing and supports callbacks after initialization.
  • Custom Widgets:
    • Included custom built widgets for enhanced interaction.
    • Pass any DOMWidget as a parameter to interact/interactive functions unlike default ipywidgets.interactive behavior.
    • Observe any trait of the widget by 'widget_name.trait_name' where 'widget_name' is assigned to a widget/fixed(widget) in control parameters, OR '.trait_name' if trait_name exists on instance of interactive.
    • Tuple pattern (widget, 'trait') for trait observation where widget is accessible via params and trait value goes to callback. This is useful to have widget and trait in a single parameter, such as x = (fig, 'selected') for plotly FigureWidget. Other traits of same widget can be observed by separate parameters with y = 'x.trait' pattern.
    • You can use '.fullscreen' to detect fullscreen change and do actions based on that.
    • Use .params to acess widgets built with given parameters.
    • Use var to observe any python variable which is not a widget and trigger callbacks when var.value changes.
    • Add ipywidgets.Button to hold callbacks which use it as paramter for a click
  • Plotly Integration: Modified plotly support with additional traits like selected and clicked
  • Markdown support:
    • Convert markdown to HTML widget using dashlab.markdown function.
    • hstack and vstack functions support markdown strings to automatically convert to HTML and place in stack.
  • JupyTimer: A non-blocking widget timer for Jupyter Notebooks without threading/asyncio.
  • Event Callbacks: Easy widget event handling with the @callback decorator inside the subclass of DashboardBase or multiple functions in interact/interactive functions.
  • Full Screen Mode: Transform your dashboards into full-screen applications by added button.

Usage Example

import numpy as np
import matplotlib.pyplot as plt
import ipywidgets as ipw
import pandas as pd
import plotly.graph_objects as go
import dashlab as dl

dash = dl.Dashboard(
    fig = dl.patched_plotly(go.FigureWidget()), 
    html = dl.markdown('**Select Box/Lesso on figure traces**'),
    A = (1,10), omega = (0,20), phi = (0,10),
    sdata = 'fig.selected', cdata = 'fig.clicked', fs = '.isfullscreen',
)
@dash.callback('out-click', throttle = 200) # limit click rate by 200 ms
def on_click(cdata,html):
    display(pd.DataFrame(cdata or {}))

@dash.callback('out-select')
def on_select(sdata, html):
    plt.scatter(sdata.get('xs',[]),sdata.get('ys',[]))
    plt.show()

@dash.callback('out-fs')
def detect_fs(fig, fs):
    print("isfullscreen = ",fs)
    fig.layout.autosize = False # double trigger
    fig.layout.autosize = True

@dash.callback
def plot(fig:go.FigureWidget, A, omega,phi): # adding type hint allows auto-completion inside function
    fig.data = []
    x = np.linspace(0,10,100)
    fig.add_trace(go.Scatter(x=x, y=A*np.sin(omega*x + phi), mode='lines+markers'))

dash.set_css({
    '.left-sidebar':{'background':'whitesmoke'},
    ':fullscreen': {'height': '100vh'}}
)
dash.set_layout(
    left_sidebar=['A','omega','phi','html', 'out-select','out-main'], 
    center=['fig','out-click'], 
    pane_widths=[3,7,0],
)

dash

dashboard.gif

Comprehensive Examples

  • Check out the demo.ipynb which demonstates subclassing DashboardBase, using custom widgets, and observing multiple functions through the @callback decorator.
  • See Bandstructure Visualizer and KPath Builder as comprehensive dashboards.

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

dashlab-0.3.4.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dashlab-0.3.4-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

Details for the file dashlab-0.3.4.tar.gz.

File metadata

  • Download URL: dashlab-0.3.4.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for dashlab-0.3.4.tar.gz
Algorithm Hash digest
SHA256 cb7ae8521472acfee8fcce42e9f1c144def7335951392ec77c5dc7c84f043442
MD5 f1ce09f8031d15f855aa8cc3bdb4d67d
BLAKE2b-256 e1c9e42c3c5c25ae359dc7fe32cdba0268ce1238a1c5946d7a355276efa6b40c

See more details on using hashes here.

File details

Details for the file dashlab-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: dashlab-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 47.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for dashlab-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5f3b4f85bec6359bd87f8a44ea9f70fdcfe061293abde57b42c19bddd51e7a9c
MD5 a0fba26c8abd70b09d9f1d37441d9b8f
BLAKE2b-256 220cc23b2132973a9a876fc12fab03f539f9b9cb6cd500100b49041db329325f

See more details on using hashes here.

Supported by

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