Skip to content

Instantly share code, notes, and snippets.

View AnnMarieW's full-sized avatar

Ann Marie Ward AnnMarieW

View GitHub Profile
@AnnMarieW
AnnMarieW / file_tree_accordion.py
Created October 8, 2022 17:48
Display a file directory using dmc.Accordion
from dash import Dash
import dash_mantine_components as dmc
from dash_iconify import DashIconify
app = Dash(__name__)
pages = ["home.py", "page1.py", "page2.py"]
assets = ["mycss.css", "app.png", "page1.png"]
@AnnMarieW
AnnMarieW / changed_cell.py
Created October 7, 2022 15:55
clientside callback to determine which cell of a DataTable was changed
# from Adam's video https://www.youtube.com/watch?v=2pWwSm6X24o&list=PLh3I780jNsiQObs1CGDIB1S_I7--M40yC
# data is stored in a dcc.Store(id="changed-cell")
app.clientside_callback(
"""
function (input,oldinput) {
@AnnMarieW
AnnMarieW / live_crypto_prices.py
Created October 1, 2022 18:51
Live crypto price updates in a Bootstrap Card
from dash import Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
import requests
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.BOOTSTRAP])
def get_data(coin):
try:
@AnnMarieW
AnnMarieW / histogram_simulation.py
Last active September 30, 2022 02:15
Histogram Simulation
from dash import Dash, html, dcc, Input, Output
import numpy as np
import plotly.express as px
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
heading = html.H4(
"Normal Distribution Simulation", className="bg-primary text-white p-4"
@AnnMarieW
AnnMarieW / histogram_simulation.py
Created September 29, 2022 21:31
Histogram Simulation
from dash import Dash, html, dcc, Input, Output
import numpy as np
import plotly.express as px
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
heading = html.H4(
"Normal Distribution Simulation", className="bg-primary text-white p-4"
)
@AnnMarieW
AnnMarieW / dropdown_with_select_all.py
Created September 29, 2022 21:10
Multi Dropdown with a Select All button
from dash import Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
options = ["apples", "oranges", "bananas", "chocolate"]
app.layout = dbc.InputGroup(
[
dcc.Dropdown(options, multi=True, id="fruit", style={"width":400}),
@AnnMarieW
AnnMarieW / dropdown-bootstrap-theme-swatch.py
Created September 25, 2022 16:27
Dropdown with Bootstrap theme color swatch
# todo -add images for other themes
from dash import Dash, html, dcc
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
themes = {
@AnnMarieW
AnnMarieW / figure_templates.py
Created September 8, 2022 16:22
Plotly figure templates and Bootstrap themed figure templates
from dash import Dash, dcc, html, Input, Output
import plotly.express as px
from dash_bootstrap_templates import load_figure_template
import dash_mantine_components as dmc
app = Dash(__name__)
iris = px.data.iris()
gapminder = px.data.gapminder()
tips = px.data.tips()
@AnnMarieW
AnnMarieW / center_cards_in_row_bootstrap.py
Created August 22, 2022 15:02
Center a card in a row with Dash Bootstrap Components
from dash import Dash, html
import dash_bootstrap_components as dbc
app = Dash(
__name__,
external_stylesheets=[dbc.themes.BOOTSTRAP],
)
card = dbc.Card(
@AnnMarieW
AnnMarieW / sidebar_expand_on_hover.py
Created August 18, 2022 17:20
Sidebar with icons -- expands to show description and link on hover
"""
Credit: This cool sidebar is from https://github.com/sohibjon07012001/Dash_Pages
Put this in a .css file in the assets folder:
/* This creates a skinny side bar fixed to the left of the page */
.sidebar {
position: fixed;
top: 0;
left: 0;