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.
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 .
✨ Try it in your browser ✨
| Jupyter Lab | Notebook | Binder |
|—-|—|— |
| |
|
|
dashlab.DashboardBase
class and defining methods with the @callback
decorator.interact/interactive
functions unlike default ipywidgets.interactive
behavior.'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..params
to acess widgets built with given parameters.var
to observe any python variable which is not a widget and trigger callbacks when var.value
changes.ipywidgets.Button
to hold callbacks which use it as paramter for a clickselected
and clicked
dashlab.markdown
function.hstack
and vstack
functions support markdown strings to automatically convert to HTML and place in stack.@callback
decorator inside the subclass of DashboardBase
or multiple functions in interact/interactive
functions.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
DashboardBase
, using custom widgets, and observing multiple functions through the @callback
decorator.