= cond_pico_hdrs()+bootstrap_hdrs()+datatable_hdrs()+download_js() hdrs
Plot
Setup
*hdrs) show(
from ngrok_token import *
= start_ngrok(token)
url url
ngrok tunnel opened at: https://b4e9-3-81-185-19.ngrok-free.app
'https://b4e9-3-81-185-19.ngrok-free.app'
= fast_app(pico=False, live=True,hdrs=hdrs)
app,rt = JupyUvi(app) server
SVG Decorator
fh_svg
fh_svg (func)
svg to fasthtml item
Use decorator to convert svg to fasthtml item
Heatmap
fh_svg..wrapper
fh_svg.<locals>.wrapper (*args, **kwargs)
= np.random.rand(20, 10)
matrix = pd.DataFrame(matrix) df
plot_heatmap(df)
Bar plot
fh_svg..wrapper
fh_svg.<locals>.wrapper (*args, **kwargs)
= np.random.rand(7, 2)
matrix = pd.DataFrame(matrix)
df
= ['ctrl','exp'] df.columns
=(4,2)) plot_bar(df,figsize
Download plot
download_svg
download_svg (*args, txt=' Plot', **kwargs)
The figure and download button has to bee placed within the same Div()
@rt
def test():
return Div(download_svg(),Div(plot_bar(df,figsize=(4,2))))
'/test') htmx(url,
End
server.stop() kill_ngrok()
ngrok tunnel killed