Dash Python extention for rendering Jinja2 templates.
Project description
dash-template-rendering
Dash Python extention for rendering Jinja2 templates.
Simple example
Based on the dash minimal app.
from dash import Dash, html, dcc, callback, Output, Input
from dash_template_rendering import TemplateRenderer, render_dash_template_string
import plotly.express as px
import pandas as pd
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv"
)
app = Dash(__name__)
TemplateRenderer(dash=app)
app.layout = render_dash_template_string(
"""
<div>
<h1 style="text-align:center;">Title of Dash App</h1>
{{ dropdown | plotly }}
{{ graph | plotly }}
<h3>You can use all jinja2 features too.</h3>
<ul>
{% for i in [1,2,3] %}
<li>Item {{ i }}</li>
{% endfor %}
</ul>
</div>
""",
dropdown=dcc.Dropdown(df.country.unique(), "Canada", id="dropdown-selection"),
graph=dcc.Graph(id="graph-content"),
)
@callback(Output("graph-content", "figure"), Input("dropdown-selection", "value"))
def update_graph(value):
dff = df[df.country == value]
return px.line(dff, x="year", y="pop")
if __name__ == "__main__":
app.run_server(debug=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for dash-template-rendering-0.0.1a1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0439b3b72cd4ed8ffa72b5d0d098b4fd69d9d369fd4dba091ed2d82e8bfae98f |
|
MD5 | 20e2c494308d6e51c11bd1ff57b8187d |
|
BLAKE2b-256 | 1afde774b96770173500818c7b6387ab5cf101e31547f0629d7c6be81bb304a5 |
Close
Hashes for dash_template_rendering-0.0.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83fbdcff3e8889bfd241a9c83d29a7095725da96e43a1bcd64482230943c640c |
|
MD5 | de38e800b053399e8b7c3f1287f47e29 |
|
BLAKE2b-256 | 37e1427a06a86bff73deba0f1b77339094f20291e0d69c6bceb4735eef7f23ab |