Skip to content

Instantly share code, notes, and snippets.

View AnnMarieW's full-sized avatar

Ann Marie Ward AnnMarieW

View GitHub Profile
@AnnMarieW
AnnMarieW / datatable_html.py
Last active May 28, 2022 17:11
Dash DataTable - format cells with html
# https://community.plotly.com/t/different-colour-for-each-wrapped-text/64566/6
# Dash DataTable formatting cells with html
from dash import Dash, dash_table
import pandas as pd
data = dict(
[
("Date",["2015-01-01", "2015-10-24","2016-05-10"]),
("values", ["1\n1.2\n1.3", "2\n2.2\n2.3", "3\n3.2\n3.3"]),
@AnnMarieW
AnnMarieW / dmc_timeline_with_icons.py
Created May 28, 2022 18:46
Timeline component with icons from dash-mantine-components and DashIconify
# Timeline component with icons from dash-mantine-components and DashIconify
import dash_mantine_components as dmc
from dash import Dash
from dash_iconify import DashIconify
app = Dash(__name__)
def make_icon(icon):
@AnnMarieW
AnnMarieW / pattern_matching_with_delete.py
Last active May 30, 2022 18:23
Dash Pattern Matching Callback with delete option
from dash import Dash, dcc, html, Input, Output, State, ALL, MATCH, ctx
import plotly.express as px
import dash_bootstrap_components as dbc
df = px.data.gapminder()
default_column_x = "year"
default_column_y = "gdpPercap"
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
@AnnMarieW
AnnMarieW / expanding_text_input_fields.py
Created June 3, 2022 13:55
Expanding Text Input Fields with CSS from the [Dash Community Forum](https://community.plotly.com/t/expanding-text-input-fields/64735/3)
from dash import Dash, html, dcc, clientside_callback, Output, Input
app = Dash(__name__)
app.layout = html.Div(
[
html.Label(
[
html.Span("Name: "),
dcc.Input(id="name_input", size="4", placeholder="John")
@AnnMarieW
AnnMarieW / datatable_with_links.py
Created June 8, 2022 00:48
Dash DataTable with links
@AnnMarieW
AnnMarieW / smooth_figure_update.py
Last active June 15, 2022 18:06
Using clientside callback to update a figure with real time data
# See more info: https://stackoverflow.com/questions/63589249/plotly-dash-display-real-time-data-in-smooth-animation/63681810#63681810
from dash import Dash, dcc, html
import numpy as np
from dash.dependencies import Input, Output, State
# Example data (a circle).
resolution = 1000
@AnnMarieW
AnnMarieW / popover_dropdown_menu.py
Created June 20, 2022 00:42
Cool way to make a "dropdown" using a dbc.Popover
import dash_bootstrap_components as dbc
from dash import Dash, html
app = Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB, dbc.icons.BOOTSTRAP])
app.layout = dbc.Container(
[
html.Span(
[
@AnnMarieW
AnnMarieW / markdown_with_dcc_link.py
Created June 23, 2022 23:58
Dash: Use dcc.Link in a dcc.Markdown component for high performance links that don't refresh the page
@AnnMarieW
AnnMarieW / dmc_date_pickers_locale.py
Last active July 3, 2022 17:32
Dash Mantine Components DatePicker with Locale
from dash import Dash
import dash_mantine_components as dmc
scripts = [
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/dayjs.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.8/locale/fr.min.js",
]
# Default is English. To change the locale be sure to include proper localization file from dayjs library.
# See more options here:
@AnnMarieW
AnnMarieW / james_webb_before_after_images.py
Created July 15, 2022 06:14
Dash App - James Webb Telescope - Before and After Images
from dash import Dash, html
from dash_extensions import BeforeAfter
import dash_bootstrap_components as dbc
deep_field = "https://user-images.githubusercontent.com/72614349/179115661-f8de6e4c-0dca-4628-ab67-3d525f5ac049.jpg"
stephans_quintet = "https://user-images.githubusercontent.com/72614349/179115662-32d348da-fa8b-481d-b4fc-9f7414f49de0.jpg"
webb_stephans_quintet = "https://user-images.githubusercontent.com/72614349/179115663-71578706-1ab5-45a5-b809-812c7c3028a7.jpg"
carina = "https://user-images.githubusercontent.com/72614349/179115665-9800b45c-e1dc-4aa7-8b34-885d48c61221.png"
southern_nebula = "https://user-images.githubusercontent.com/72614349/179115666-fdd204fc-e33d-4524-9ba5-a2611740f8a7.jpg"
webb_deep_field = "https://user-images.githubusercontent.com/72614349/179115668-2630e3e4-3a9f-4c88-9494-3412e606450a.jpg"