Created
March 31, 2020 13:23
-
-
Save allatambov/cdecca50d511024ae10e685081303cea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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