import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
from dash.dependencies import Input, Output | |
import pandas as pd | |
df = pd.read_csv("https://allatambov.github.io/pydj/seminars/wgi-new.csv") | |
tab = df["fh_type"].value_counts() | |
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] | |
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) | |
app.layout = html.Div(children=[ | |
html.H1(children='WGI Data'), | |
dcc.Dropdown(id = 'menu', | |
options = [ | |
{'label' : 'Red', 'value' : '#c72418'}, | |
{'label' : 'Green', 'value' : '#15bd23'}, | |
{'label' : 'Blue', 'value' : '#5d59d9'}], | |
value = '#15bd23'), | |
dcc.Graph(id = 'bar')]) | |
@app.callback(Output('bar', 'figure'), | |
[Input('menu', 'value')]) | |
def update_graph(value): | |
return {'data' : [{'x' : tab.index, | |
'y' : tab.values, | |
'type': 'bar', | |
'name': 'Countries', | |
'marker': {'color' : value}}], | |
'layout': { | |
'title': 'Dash Data Visualization' | |
} | |
} | |
if __name__ == '__main__': | |
app.run_server(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment