diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42ce786..7797dc6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,11 +24,11 @@ jobs: - name: Build package run: python -m build --sdist --wheel --outdir dist/ - # - name: Publish dash-bootstrap-templates to TestPyPI - # uses: pypa/gh-action-pypi-publish@v1.4.2 - # with: - # password: ${{ secrets.TEST_PYPI_API_TOKEN }} - # repository_url: https://test.pypi.org/legacy/ + - name: Publish dash-bootstrap-templates to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.4.2 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ # - name: Publish dash-bootstrap-templates to PyPI # uses: pypa/gh-action-pypi-publish@v1.4.2 diff --git a/README.md b/README.md index 353eaaa..e68a099 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ This library has a template for each of the 22 Bootstrap/Bootswatch themes avail [Dash Bootstrap Components Library](https://dash-bootstrap-components.opensource.faculty.ai/). ## Quickstart +```python" +pip install dash-bootstrap-templates +``` ```python @@ -106,3 +109,7 @@ valid_themes = [ "solar", "superhero", ] + +### Contributors +Special thanks to @tcbegley for [the pull request](https://github.com/AnnMarieW/dash-bootstrap-templates/pull/2) to +set up this library to publish to PyPI \ No newline at end of file diff --git a/examples/dl_demo_4figures.py b/examples/dl_demo_4figures.py index da18079..0caff6a 100644 --- a/examples/dl_demo_4figures.py +++ b/examples/dl_demo_4figures.py @@ -160,120 +160,3 @@ def update_charts(indicator, continents, years): - -from dash_bootstrap_templates import load_figure_template - -import dash -import dash_labs as dl -import dash_core_components as dcc -import dash_html_components as html -import plotly.express as px -import dash_bootstrap_components as dbc - - - -tpl = dl.templates.dbc.DbcSidebar( - title="Dash Bootstrap Template Demo", - sidebar_columns=3, - theme=dbc.themes.FLATLY, # change theme here - figure_template=True -) - -app = dash.Dash(__name__, plugins=[dl.plugins.FlexibleCallbacks()]) - -df = px.data.gapminder() - -dropdown = dcc.Dropdown( - id="indicator", - options=[{"label": str(i), "value": i} for i in ["gdpPercap", "lifeExp", "pop"]], - value="gdpPercap", - clearable=False, -) - - -checklist = dbc.Checklist( - id="continents", - options=[{"label": i, "value": i} for i in df.continent.unique()], - value=df.continent.unique()[1:], - inline=True, -) - -years = df.year.unique() -range_slider = dcc.RangeSlider( - id="slider_years", - min=years[0], - max=years[-1], - step=5, - marks={int(i): str(i) for i in [1952,1962,1972,1982,1992,2002,2007]}, - value=[1982, years[-1]], -) - -badges = html.Div( - [ - dbc.Badge("Primary", color="primary", className="mr-1"), - dbc.Badge("Secondary", color="secondary", className="mr-1"), - dbc.Badge("Success", color="success", className="mr-1"), - dbc.Badge("Warning", color="warning", className="mr-1"), - dbc.Badge("Danger", color="danger", className="mr-1"), - dbc.Badge("Info", color="info", className="mr-1"), - dbc.Badge("Light", color="light", className="mr-1"), - dbc.Badge("Dark", color="dark", className="mr-1"), - ] -) - - -@app.callback( - dl.Input(dropdown, label="Select indicator (y-axis)"), - dl.Input(checklist, label="Select continents"), - dl.Input(range_slider, label="Select time period"), - template=tpl, -) -def update_charts(indicator, continents, years): - if continents == [] or indicator is None: - return {}, {} - - dff = df[df.year.between(years[0], years[1])] - dff = dff[dff.continent.isin(continents)] - line_fig = px.line( - dff, x="year", y=indicator, color="continent", line_group="country" - ) - - dff = dff[dff.year == years[1]] - scatter_fig = px.scatter( - dff, x="lifeExp", y=indicator, size="pop", color="pop", size_max=60 - ).update_traces(marker_opacity=0.8) - - avg_lifeExp = (dff["lifeExp"] * dff["pop"]).sum() / dff["pop"].sum() - map_fig = px.choropleth( - dff, - locations="iso_alpha", - color="lifeExp", - title="%.0f World Average Life Expectancy was %.1f years" % (years[1], avg_lifeExp), - ) - - hist_fig = px.histogram(dff, x="lifeExp", nbins=10, title="Life Expectancy") - - return html.Div( - [ - dbc.Row( - [ - dbc.Col(dcc.Graph(figure=line_fig), lg=6), - dbc.Col(dcc.Graph(figure=scatter_fig), lg=6), - ] - ), - dbc.Row( - [ - dbc.Col(dcc.Graph(figure=hist_fig), lg=6), - dbc.Col(dcc.Graph(figure=map_fig),lg=6), - ] - ), - ] - ) - - -tpl.add_component(badges, role="input", after=2) -app.layout = tpl.layout(app) - - -if __name__ == "__main__": - app.run_server(debug=True)