Commit 11c51253 authored by Christophe Benz's avatar Christophe Benz

Init

parents
Pipeline #1674 failed with stages
in 35 seconds
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.py]
max_line_length = 88
indent_style = space
indent_size = 4
[*.{rst,ini,cfg}]
indent_style = space
indent_size = 4
[*.{md,yml}]
indent_style = space
indent_size = 2
.mypy_cache/
from operator import itemgetter
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
def create_figure(town: str = None):
if town is None:
title = "All towns"
data = [
{
"x": town_data.get("x"),
"y": town_data.get("y"),
"type": "bar",
"name": town_data["title"],
}
for town_data in sorted(towns.values(), key=itemgetter("title"))
]
else:
town_data = towns[town]
title = town_data["title"]
data = [
{
"x": town_data.get("x"),
"y": town_data.get("y"),
"type": "bar",
"name": title,
}
]
return {
"data": data,
"layout": {"title": title},
}
towns = {
"NYC": {"title": "New York City"},
"MTL": {"title": "Montréal", "x": [1, 2, 3], "y": [2, 4, 5]},
"SF": {"title": "San Francisco", "x": [1, 2, 3], "y": [4, 1, 2]},
}
initial_town = "MTL"
app = dash.Dash(__name__)
app.layout = html.Div(
children=[
html.H1(children="Hello Dash"),
html.Div(
children="""
Dash: A web application framework for Python.
"""
),
dcc.Dropdown(
id="town",
options=[
{"label": town_data["title"], "value": value}
for value, town_data in towns.items()
],
value=initial_town,
),
html.Div(id="label1"),
html.Div(
children=[
dcc.Graph(id="graph-selected", figure=create_figure(town=initial_town)),
dcc.Graph(id="graph-all", figure=create_figure()),
],
style={"columnCount": 2},
),
]
)
@app.callback(
Output(component_id="graph-selected", component_property="figure"),
[Input(component_id="town", component_property="value")],
)
def update_trucmuche(input_value):
return create_figure(town=input_value)
if __name__ == "__main__":
app.run_server(debug=True)
black
flake8
isort
mypy
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
#
click==7.0 # via flask
dash-core-components==1.6.0 # via dash
dash-html-components==1.0.2 # via dash
dash-table==4.5.1 # via dash
dash==1.7.0
dash_renderer==1.2.2 # via dash
flask-compress==1.4.0 # via dash
flask==1.1.1 # via dash, flask-compress
future==0.18.2 # via dash
itsdangerous==1.1.0 # via flask
jinja2==2.10.3 # via flask
markupsafe==1.1.1 # via jinja2
plotly==4.4.1 # via dash
retrying==1.3.3 # via plotly
six==1.13.0 # via plotly, retrying
werkzeug==0.16.0 # via flask
[flake8]
# From https://pypi.org/project/flake8-black/
# Recommend matching the black line length (default 88),
# rather than using the flake8 default of 79:
max-line-length = 88
extend-ignore =
E203, # See https://github.com/PyCQA/pycodestyle/issues/373
D202, # See https://github.com/PyCQA/pydocstyle/pull/395
enable-extensions=G # for flake8-logging-format
[isort]
# From https://black.readthedocs.io/en/stable/the_black_code_style.html#how-black-wraps-lines
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
[pycodestyle]
max_line_length = 88
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment