Skip to content

Instantly share code, notes, and snippets.

View AnnMarieW's full-sized avatar

Ann Marie Ward AnnMarieW

View GitHub Profile
import dash
from dash import Dash, dash_table, dcc, html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.express as px
df = px.data.tips()
df["id"] = df.index
@AnnMarieW
AnnMarieW / datatable_icons.py
Created November 12, 2022 17:29
DataTable with icons
"""
See other MWEs for images and text icons here: https://github.com/plotly/dash-table/pull/916
Css in assets folder: (not tested yet maybe move the body font-size somewhere else since it will affect the entire app like this)
.cell-markdown > p {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
@AnnMarieW
AnnMarieW / space_dependency_parse.py
Last active December 16, 2022 18:58
spacy named entities app
from dash import Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
import spacy
from spacy import displacy
import base64
nlp = spacy.load("en_core_web_sm")
@AnnMarieW
AnnMarieW / set_drilldown_order.py
Last active October 24, 2022 18:05
Set drilldown order of bar charts and sunburst - Two versions
"""
From dash community question:
https://community.plotly.com/t/how-can-i-allow-users-to-select-which-comparison-variables-to-display-on-a-chart/69124
"""
from dash import Dash, html, dcc, Input, Output
import plotly.express as px
import pandas as pd
import dash_bootstrap_components as dbc
@AnnMarieW
AnnMarieW / live_crypto_prices_dark_theme.py
Last active October 12, 2022 18:22
Live Crypto prices Dark Theme
import dash
from dash import Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
import requests
app = Dash(__name__, external_stylesheets=[dbc.themes.SUPERHERO, dbc.icons.BOOTSTRAP])
coins = ["bitcoin", "ethereum", "binancecoin", "ripple"]
interval = 6000 # update frequency - adjust to keep within free tier
api_url = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd"
@AnnMarieW
AnnMarieW / ThemeSwitchAIO_with_grey_background.py
Created October 10, 2022 16:25
Sample App from HelloDash with ThemeSwitchAIO - How to make a light grey background
from dash import Dash, dcc, html, dash_table, Input, Output, callback
import plotly.express as px
import dash_bootstrap_components as dbc
from dash_bootstrap_templates import ThemeSwitchAIO
# select the Bootstrap stylesheet2 and figure template2 for the theme toggle here:
template_theme1 = "minty"
template_theme2 = "cyborg"
url_theme1 = dbc.themes.MINTY
@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"