Exemplo n.º 1
0
import sys
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from web_app.app import app
from web_app.apps import customer_dashboard, overall_dashboard

sys.path.append(r"E:\VIL Codefest\CustomDash")

app.layout = html.Div([
    dcc.Location(id='url', refresh=False, pathname='/apps/customer_dashboard'),
    html.Div(id='page-content')
])


@app.callback(Output('page-content', 'children'), [Input('url', 'pathname')])
def display_page(pathname):
    print(pathname)
    if pathname == '/apps/customer_dashboard':
        return customer_dashboard.layout
    elif pathname == '/apps/overall_dashboard':
        return overall_dashboard.layout
    else:
        return '404'


if __name__ == '__main__':
    app.run_server(debug=False)
Exemplo n.º 2
0
                                                     "width": "70%"},
                                              className="six columns")], className="row"),
                       dcc.Graph(id="my-graph")
                       ], className="container")


@app.callback(
    dash.dependencies.Output("my-graph", "figure"),
    [dash.dependencies.Input("value-selected", "value")]
)
def update_figure(selected):
    dff = df.groupby(['iso_alpha', 'country']).mean().reset_index()
    def title(text):
        if text == "pop":
            return "Poplulation (million)"
        elif text == "gdpPercap":
            return "GDP Per Capita (USD)"
        else:
            return "Life Expectancy (Years)"
    trace = go.Choropleth(locations=dff['iso_alpha'],z=dff[selected],text=dff['country'],autocolorscale=False,
                          colorscale="YlGnBu",marker={'line': {'color': 'rgb(180,180,180)','width': 0.5}},
                          colorbar={"thickness": 10,"len": 0.3,"x": 0.9,"y": 0.7,
                                    'title': {"text": title(selected), "side": "bottom"}})
    return {"data": [trace],
            "layout": go.Layout(title=title(selected),height=800,geo={'showframe': False,'showcoastlines': False,
                                                                      'projection': {'type': "miller"}})}


if __name__ == '__main__':
    app.run_server(debug=True)