Skip to content

Instantly share code, notes, and snippets.

Created Mar 31, 2020
What would you like to do?
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("")
tab = df["fh_type"].value_counts()
external_stylesheets = ['']
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__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment