├── README.md └── pydash.py /README.md: -------------------------------------------------------------------------------- 1 | # Plotly_Dash_Web_App_DataScience 2 | It's a repository which contain source code for building python based plotly dash web apps. One can follow the tutorial to build beautiful Analytics & Data Science related interactive and dynamic dashboards. Various HTML components like slider , drop down, check boxes can be utilized to alter the graphs. One can see the outputs in the web browser. 3 | -------------------------------------------------------------------------------- /pydash.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Apr 10 13:54:01 2019 4 | 5 | @author: Nitin 6 | """ 7 | 8 | # Import Necessary Libraries related to HTML tags and various core components like slider, checboxes, dropdowns etc. 9 | import dash 10 | import dash_html_components as html 11 | import dash_core_components as dcc 12 | 13 | #Code to start an application 14 | app = dash.Dash() 15 | 16 | #HTML layout and Graph components are defined in this section 17 | app.layout = html.Div(children=[html.H1(children='Sample Dash Web App Dashboard'), 18 | 19 | #----------------------- 20 | html.Div( 21 | [ 22 | html.Div( 23 | [ 24 | html.P('Choose Item:'), 25 | dcc.Checklist( 26 | id = 'Item_List', 27 | options=[ 28 | {'label': 'Bread', 'value': 'Bread'}, 29 | {'label': 'Milk', 'value': 'Milk'}, 30 | {'label': 'Sugar', 'value': 'Sugar'} 31 | ], 32 | values=['Bread', 'Milk', 'Sugar'], 33 | labelStyle={'display': 'inline-block'} 34 | ), 35 | ], 36 | className='six columns', 37 | style={'margin-top': '10'} 38 | ), 39 | ], className="row" 40 | ), 41 | #----------------------- 42 | 43 | html.Div(children = '''Dash: A web based app to show Bar Graph'''), 44 | dcc.Graph(id='dash_graph', 45 | 46 | ), 47 | dcc.Graph(id='dash_graph_2', 48 | figure = {'data': [{'x':[1,2,3,4,5], 'y':[4,6,3,8,1], 'type': 'bar', 'name':'Aeroplane'}, 49 | {'x':[1,2,3,4,5], 'y':[9,3,1,9,4], 'type': 'bar', 'name':'Car'}, 50 | {'x':[1,2,3,4,5], 'y':[4,6,3,8,1], 'type': 'line', 'name':'Train'},], 51 | 'layout':{'title': 'Dash Example App 2'} 52 | } 53 | ) 54 | ]) 55 | 56 | 57 | @app.callback( 58 | dash.dependencies.Output('dash_graph', 'figure'), 59 | [dash.dependencies.Input('Item_List', 'values')]) 60 | def update_graph(selector): 61 | data = [] 62 | if 'Bread' in selector: 63 | data.append({'x':[1,2,3,4,5], 'y':[4,6,3,8,1], 'type': 'bar', 'name':'Bread'}) 64 | if 'Milk' in selector: 65 | data.append({'x':[1,2,3,4,5], 'y':[9,3,1,9,4], 'type': 'bar', 'name':'Milk'}) 66 | if 'Sugar' in selector: 67 | data.append({'x':[1,2,3,4,5], 'y':[4,6,3,8,1], 'type': 'bar', 'name':'Sugar'}) 68 | figure = { 69 | 'data': data, 70 | 'layout': { 71 | 'title': 'Item Graph', 72 | 'xaxis' : dict( 73 | title='X-Axis', 74 | titlefont=dict( 75 | family='Calibri, monospace', 76 | size=20, 77 | color='#3FFF33' 78 | )), 79 | 'yaxis' : dict( 80 | title='Y-Axis', 81 | titlefont=dict( 82 | family='Garamond, monospace', 83 | size=20, 84 | color='#F9FF33' 85 | )) 86 | } 87 | } 88 | return figure 89 | 90 | #Code to run the application 91 | if __name__ == '__main__': 92 | app.run_server(debug = True) --------------------------------------------------------------------------------