import pandas as pd df = pd.read_excel( "https://github.com/chris1610/pbpython/blob/master/data/salesfunnel.xlsx?raw=True" ) pv = pd.pivot_table(df, index=['Name'], columns=["Status"], values=['Quantity'], aggfunc=sum, fill_value=0) trace1 = go.Bar(x=pv.index, y=pv[('Quantity', 'declined')], name='Declined') trace2 = go.Bar(x=pv.index, y=pv[('Quantity', 'pending')], name='Pending') trace3 = go.Bar(x=pv.index, y=pv[('Quantity', 'presented')], name='Presented') trace4 = go.Bar(x=pv.index, y=pv[('Quantity', 'won')], name='Won') app = DjangoDash('SimpleExample') app.layout = html.Div(children=[ html.H1(children='Sales Funnel Report'), html.Div(children='''National Sales Funnel Report.'''), dcc.Graph(id='example-graph', figure={ 'data': [trace1, trace2, trace3, trace4], 'layout': go.Layout(title='Order Status by Customer', barmode='stack') }) ])
app.layout = html.Div([ dcc.Upload( id='upload-data', children=html.Div([ 'Drag and Drop or ', html.A('Select Files') ]), style={ 'width': '100%', 'height': '60px', 'lineHeight': '60px', 'borderWidth': '1px', 'borderStyle': 'dashed', 'borderRadius': '5px', 'textAlign': 'center', 'margin': '10px' }, # Allow multiple files to be uploaded multiple=False ), html.Div(id='output-data-upload'), html.Hr(), # callback선언을 위해서는 이쪽에 기본적으로 모든 component를 배치해야 합니다. # 파일을 올리면 동적으로 그려주고, 해당 element에 callback을 걸고 싶은데, # callback처리대상은 미리 모두 선언해두어야 한다고 합니다. # https://community.plot.ly/t/dynamic-controls-and-dynamic-output-components/5519 html.Div( [ html.H6('x:'), ColumnChecklist, html.H6('y:'), ColumnSelector, html.Hr(), html.P('x값과 y값을 선택하고 완료버튼을 누르세요.'), ColumnSubmitButton, html.H6('Result:'), html.Div(id='check-result'), ], id='upload-result-section', ), html.Hr(), html.Div(id='slider-value'), html.Div(id='slider-output') ], className='container')
html.Div(id="tabs-content"), ])) ]), html.Div(id="selection-output"), html.Div(id="selected-raw-files", style={"visibility": "hidden"}), dcc.Loading( html.Div(id="shapley-values", style={"visibility": "hidden"})), ], style={ "max-width": "90%", "display": "block", "margin": "auto" }, ) app.layout = layout proteins.callbacks(app) explorer.callbacks(app) anomaly.callbacks(app) @app.callback(Output("tabs-content", "children"), [Input("tabs", "value")]) def render_content(tab): if tab == "proteins": return proteins.layout if tab == "quality_control": return quality_control.layout if tab == "explorer": return explorer.layout if tab == "anomaly":
app_name = "dash_hexplot" dash_app = DjangoDash( name=app_name, serve_locally=False, app_name=app_name, meta_tags=[ {"name": "viewport", "content": "width=device-width, initial-scale=1.0"} ], external_stylesheets=[dbc.themes.BOOTSTRAP], add_bootstrap_links=True, ) dash_app.layout = serve_layout @dash_app.callback( Output("interval-component", "disabled"), [Input("reload-box", "on")], ) def start_reload_counter(reload_box): """Track the reload status for data.""" return not reload_box @dash_app.callback( Output("auto-time", "children"), [ Input("session-id", "children"), Input("interval-component", "n_intervals"),
eduDataFrame["edu"] = edu eduDataFrame["count"] = count eduDataFrame["eduCD4"] = eduCD4 # print(eduDataFrame) external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('eduCD4', external_stylesheets=external_stylesheets) app.layout = html.Div([ dcc.Graph(id='graph-with-slider'), dcc.Slider( id='date-slider', min=0, max=len(dataDate) - 1, marks={i: dataDate[i][0] for i in range(len(dataDate))}, value=0, ) ]) @app.callback(Output('graph-with-slider', 'figure'), [Input('date-slider', 'value')]) def update_figure(selected_date): filtered_df = eduDataFrame[eduDataFrame.date == dataDate[selected_date][0]] fig = px.bar(filtered_df, x="edu",
Shares for currency outside banks and demand deposits were computed from money supply; while shares for money supply and quasi money were computed from broad money """), id="collapse_contrib", is_open=False), ], body=True, ) app.layout = html.Div([ html.Br(), html.Br(), dbc.Row([ dbc.Col(dropdown, md=12), dbc.Col(level, lg=6), dbc.Col(share, lg=6), dbc.Col(growth, lg=6), dbc.Col(contrib, lg=6), ]), ]) @app.callback(Output(component_id='id_level', component_property='figure'), [Input(component_id='id_client', component_property='value')]) def level(client): dff_level = df_level[df_level['Client'].isin(client)] fig = px.line( dff_level, x='year', y='level',
dbc.Row([ dbc.Col([dash_utils.get_chart_card(chart_sale_pareto_id)], sm=12, md=12, lg=6), dbc.Col( [dash_utils.get_chart_card(chart_top_delivered_total_cost_id)], sm=12, md=12, lg=6), ]), ]) return chart_container app.layout = dash_utils.get_dash_layout(filter_container(), chart_container()) @app.callback(Output(chart_stock_pareto_id, 'figure'), [ Input(dropdown_categories_id, 'value'), Input(dropdown_products_id, 'value'), Input(input_period_date_range_id, 'start_date'), Input(input_period_date_range_id, 'end_date'), Input(dropdown_group_by_field_id, 'value'), ]) def update_stock_pareto_chart(category_ids, product_ids, inventory_date_start, inventory_date_end, group_by_field): # Build filter for the query filter_kwargs = {} filter_kwargs['inventory_date__gte'] = inventory_date_start
# fig3.update_traces(selectedpoints=[], # customdata=df.index, # mode='markers+text', marker={'color': 'rgba(0, 116, 217, 0.7)', 'size': 20}, # unselected={'marker': {'opacity': 0.3}, 'textfont': {'color': 'rgba(0, 0, 0, 0)'}}) #figure는 layout에서 define하지 않는다. app.layout = html.Div(children=[ dcc.Graph(id='foo', className="four columns"), dcc.Graph(id='bar', className="four columns"), dcc.Graph(id='baz', className="four columns"), html.Label('Most recent clickdata'), html.Pre(id='update-on-click-data', style=pre_style), hidden_inputs, hidden_inputs_relay, html.Div([ dcc.Markdown(""" **Zoom and Relayout Data** Click and drag on the graph to zoom or click on the zoom buttons in the graph's menu bar. Clicking on legend items will also fire this event. """), html.Pre(id='relayout-data'), ], className='three columns') ]) #,figure = fig1 dash_input_keys = sorted(list(graph_names)) last_clicked_id = "last-clicked" last_clicked_id2 = "second-last-clicked" input_clicktime_trackers = [key + "_clicktime" for key in dash_input_keys]
from datetime import datetime import dash_bootstrap_components as dbc import dash_core_components as dcc import dash_html_components as dhc from django_plotly_dash import DjangoDash from django.urls import reverse_lazy app = DjangoDash('SkipDash', external_stylesheets=[dbc.themes.BOOTSTRAP], add_bootstrap_links=True) app.layout = dbc.Container([ dhc.Div( dbc.Row([ dbc.Col( dhc.A('View All Alerts', href='/alerts', target='_top') ), dbc.Col( dhc.A('View Swift XRT Alerts', href='/swift', target='_top') ) ]) ) ])
# app.layout = html.Div([ html.Div([html.H1('Stock Ticker Dashboard')], className='title'), html.Div([ html.H3('Choose a stock symbol: '), dcc.Dropdown(id='select_co', options=selection_co, value=['SPY'], className='dropdown', multi=True), ], className='selectors'), html.Div([ html.H3('Choose a start and end date: '), dcc.DatePickerRange(id='my-date-picker-range', min_date_allowed=datetime(1995, 8, 5), max_date_allowed=datetime.today(), start_date=datetime(2017, 1, 21), end_date=datetime.today()), ], className='selectors'), html.Div([ html.Button(id='submit-button', n_clicks=0, children='Submit', className='mybutton'), ], className='selectors selectors2'), html.H1(id='my_output'), dcc.Graph(id='my_graph') ])
'https://codepen.io/chriddyp/pen/bWLwgP.css', '//cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css' ] app = DjangoDash('Fraf_dash_fols') app.layout = html.Div([ dcc.Dropdown(id='city', options=[{ 'label': i[1], 'value': i[2] } for i in fraud_inspector_option_city()], multi=True, value='0'), dcc.DatePickerRange( id='input1', display_format='Y-M-D', start_date=(datetime.now() - timedelta(days=30)).strftime('%Y-%m-%d'), end_date=datetime.now().strftime('%Y-%m-%d'), clearable=True, with_portal=True, ), html.Button('Загрузка', id='button', style={'height': 47}), html.Div(id='output-container-button', children='Enter a value and press submit') ]) @app.callback(dash.dependencies.Output('output-container-button', 'children'), [dash.dependencies.Input('button', 'n_clicks')], [ dash.dependencies.State('city', 'value'), dash.dependencies.State('input1', 'start_date'),
app = DjangoDash('CoShareBookings') app.css.append_css({'external_url': static('/css/bWLwgP.css')}) app.layout = html.Div([ html.H4(children='Co-Share Bookings', className='widget_header'), html.Div([ dcc.Dropdown( id='hotel_group', placeholder="Select a hotel group", ), dcc.Dropdown( id='hotel', placeholder="Select a hotel", ), dcc.Dropdown( id='city', placeholder="Select a city", style={ 'font-family': '"Open Sans", "HelveticaNeue", "Helvetica Neue", "Helvetica", "Arial", "sans-serif"', 'width': '75%', } ), dcc.DatePickerRange( id='date-picker-range', ), ], ), dcc.Graph(id='bookings-graph'), ]) @app.expanded_callback(
dash_example1.layout = html.Div(id='main', children=[ html.Div([ dcc.Dropdown( id='my-dropdown1', options=[{ 'label': 'New York City', 'value': 'NYC' }, { 'label': 'Montreal', 'value': 'MTL' }, { 'label': 'San Francisco', 'value': 'SF' }], value='NYC', className='col-md-12', ), html.Div(id='test-output-div') ]), dcc.Dropdown( id='my-dropdown2', options=[{ 'label': 'Oranges', 'value': 'Oranges' }, { 'label': 'Plums', 'value': 'Plums' }, { 'label': 'Peaches', 'value': 'Peaches' }], value='Oranges', className='col-md-12', ), html.Div(id='test-output-div2'), html.Div(id='test-output-div3') ]) # end of 'main'
def _create_app(django_plotly_dash=False, ticker_filename=TICKER_FILENAME, indicator_filename=INDICATOR_FILENAME): ''' Creates dash application Args: django_plotly_dash (boolean): django_plotly_dash or not. Default value False ticker_filename (str): ticker filename. Default value TICKER_FILENAME indicator_filename (str):: indicator filename. Default value INDICATOR_FILENAME Returns: app (dash.Dash or DjangoDash): Dash or DjangoDash application ''' if django_plotly_dash == False: app = dash.Dash(__name__, external_stylesheets=EXTERNAL_STYLESHEETS) else: app = DjangoDash(APP_DJANGO_PLOTLY_DASH_NAME, add_bootstrap_links=True) df_ticker = pd.read_csv(ticker_filename) df_indicator = pd.read_csv(indicator_filename) data_end_time = dt.datetime.strptime( '2018-03-27', '%Y-%m-%d') # dt.datetime.now() quandl does not provide data updated # data_start_time = data_end_time - dt.timedelta(days = 365) window_size_bollinger_bands = DEFAULT_WINDOW_SIZE_BOLLINGER_BANDS num_of_std_bollinger_bands = DEFAULT_NUM_OF_STD_BOLLINGER_BANDS list_year = np.arange(data_end_time.date().year, data_end_time.date().year - DEFAULT_AVAILABLE_YEARS, -1) app.layout = html.Div([ dbc.Nav([ html.Div([ html.Div([ html.A( 'Data dashboard', href='/', className='navbar-brand') ], className='navbar-header'), html.Div([ html.Ul([ html.Li( html.A('Made with Udacity', href='https://www.udacity.com/')), html.Li( html. A('Github', href= 'https://github.com/simonerigoni/udacity/tree/master/data_scientist_nanodegree/core_curriculum/term_2/software_engineering/data_dashboard_project' )) ], className='nav navbar-nav') ], className='collapse navbar-collapse') ], className='container') ], className='navbar navbar-inverse navbar-fixed-top'), html.Div([ html.Div([ html.H1('Quandle Finance Explorer', className='text-center'), html.H4('Data available only to {}'.format( data_end_time.date())), html.H3('Compare Stocks'), dcc.Dropdown(id='dropdown-stock-tickers', options=[{ 'label': s[0], 'value': s[1] } for s in zip(df_ticker.Company_Name, df_ticker.Ticker)], value=DEFAULT_TICKERS, multi=True), html.H3('Timescale'), dcc.RadioItems(id='radioitems-timescale', options=[{ 'label': t, 'value': t } for t in time_dictionary], value='1Y'), html.H3('Bollinger bands parameters'), dcc.Checklist(id='checklist-enable-bollinger-bands', options=[{ 'label': 'Enable', 'value': 'enable' }], value=['enable']), html.H4('Window size'), dcc.Input(id='input-window-size-bollinger-bands', type='number', value=window_size_bollinger_bands), html.H4('Number of standard deviation'), dcc.Input(id='input-num-of-std-bollinger-bands', type='number', value=num_of_std_bollinger_bands), html.H3('Graphs'), html.Div(id='graphs'), html.H3('Indicators'), html.H4('Years'), dcc.Dropdown(id='dropdown-years', options=[{ 'label': year, 'value': year } for year in list_year], value=[ str(data_end_time.date().year), str(data_end_time.date().year - 1) ], multi=True), html.H4('Indicators'), dcc.Dropdown(id='dropdown-indicators', options=[{ 'label': s[0], 'value': s[1] } for s in zip(df_indicator.Name, df_indicator.Column_Code)], value=DEFAULT_INDICATORS, multi=True), html.Div(id='tables') ], className='container') ], className='jumbotron') ], className='container') @app.callback(dash.dependencies.Output('graphs', 'children'), [ dash.dependencies.Input('dropdown-stock-tickers', 'value'), dash.dependencies.Input('radioitems-timescale', 'value'), dash.dependencies.Input('checklist-enable-bollinger-bands', 'value'), dash.dependencies.Input('input-window-size-bollinger-bands', 'value'), dash.dependencies.Input('input-num-of-std-bollinger-bands', 'value') ]) def update_graph(stock_tickers, timescale, enable_bollinger_bands, window_size_bollinger_bands, num_of_std_bollinger_bands): ''' Update the graphs Args: stock_tickers (list): selected tickers timescale (list): selected timescale enable_bollinger_bands (str): enable or disable bollinger bands window_size_bollinger_bands (int): window size for bollinger bands num_of_std_bollinger_bands (int): number of standar deviation for bollinger bands Returns: graphs (list): list of graphs ''' data_start_time = ( data_end_time - dt.timedelta(days=time_dictionary[timescale])).date() enable_bollinger_bands = True if len( enable_bollinger_bands ) > 0 and enable_bollinger_bands[0] == 'enable' else False graphs = [] for i, ticker in enumerate(stock_tickers): graphs.append(html.H4(ticker)) try: df = quandl.get('WIKI/' + ticker, start_date=data_start_time, end_date=data_end_time) except: #graphs.append(html.H3('Data is not available for {}'.format(ticker))#, className = {'marginTop': 20, 'marginBottom': 20})) graphs.append(html.H5('Data is not available')) continue candlestick = { 'x': df.index, 'open': df['Open'], 'high': df['High'], 'low': df['Low'], 'close': df['Close'], 'type': 'candlestick', 'name': ticker, 'legendgroup': ticker, 'increasing': { 'line': { 'color': colorscale[0] } }, 'decreasing': { 'line': { 'color': colorscale[1] } } } if enable_bollinger_bands == True: bb_bands = bollinger_bands(df.Close, window_size_bollinger_bands, num_of_std_bollinger_bands) bollinger_traces = [{ 'x': df.index, 'y': y, 'type': 'scatter', 'mode': 'lines', 'line': { 'width': 1, 'color': colorscale[(i * 2) % len(colorscale)] }, 'hoverinfo': 'none', 'legendgroup': ticker, 'showlegend': True if i == 0 else False, 'name': '{} - bollinger bands'.format(ticker) } for i, y in enumerate(bb_bands)] #graphs.append(html.H4(ticker)) graphs.append( dcc.Graph( id=ticker, figure={ 'data': [candlestick] + bollinger_traces if enable_bollinger_bands == True else [candlestick], 'layout': { 'margin': { 'b': 0, 'r': 10, 'l': 60, 't': 0 }, 'legend': { 'x': 0 } } })) return graphs @app.callback(dash.dependencies.Output('tables', 'children'), [ dash.dependencies.Input('dropdown-stock-tickers', 'value'), dash.dependencies.Input('dropdown-years', 'value'), dash.dependencies.Input('dropdown-indicators', 'value') ]) def update_table(stock_tickers, years, indicators): ''' Update the tables Args: stock_tickers (list): selected tickers years (int): selected years indicators (list): selected indicators Returns: tables (list): list of tables ''' tables = [] for i, ticker in enumerate(stock_tickers): tables.append(html.H4(ticker)) try: colonne = [ 'm_ticker', 'per_end_date', 'per_type', 'per_cal_year' ] + indicators df = quandl.get_table('ZACKS/FC', paginate=False, ticker=ticker, qopts={'columns': colonne}) #cd ..print(df) except: tables.append(html.H5('Data is not available')) continue if df.empty == True: tables.append(html.H5('Data is not available')) continue df = df[df['per_type'] == 'A'] df = df[['per_cal_year'] + indicators] anni = df['per_cal_year'].to_list() #print(anni) df = df.set_index('per_cal_year') df = df.transpose() df = df.reset_index() df.columns = ['Indicator'] + [str(y) for y in anni] #print(df) tables.append( dash_table.DataTable(id=ticker, columns=[{ "name": column, "id": column } for column in df.columns], data=df.to_dict('records'))) return tables return app
from django_plotly_dash import DjangoDash external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('SimpleExample', external_stylesheets=external_stylesheets) app.layout = html.Div([ html.H1('Square Root Slider Graph'), dcc.Graph(id='slider-graph', animate=True, style={ "backgroundColor": "#1a2d46", 'color': '#ffffff' }), dcc.Slider( id='slider-updatemode', marks={i: '{}'.format(i) for i in range(20)}, max=20, value=2, step=1, updatemode='drag', ), html.Div(id='updatemode-output-container', style={'margin-top': 20}) ]) @app.callback([ Output('slider-graph', 'figure'), Output('updatemode-output-container', 'children') ], [Input('slider-updatemode', 'value')])
# style: light, dark, outdoors, # fig = dict(data=data, layout=layout) app.layout = html.Div([ html.Div('Example Div', style={ 'padding': '5rem 0', 'fontSize': 14 }), html.Div([ html.Div(dash_table.DataTable( id='demo_table', data=df.to_dict('rows'), columns=[{ 'name': i, 'id': i } for i in df.columns], n_fixed_rows=1, style_cell={'whiteSpace': 'normal'}, virtualization=True, filtering=True, sorting=True, ), className="col"), html.Div(id='demo_graphs', className="col"), ], className="row") ]) @app.callback(Output('demo_graphs', 'children'), [Input('demo_table', 'derived_virtual_data')])
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import dash import dash_bootstrap_components as dbc import dash_html_components as html from django_plotly_dash import DjangoDash dd = DjangoDash("BootstrapApplication", add_bootstrap_links=True) dd.layout = html.Div( [ dbc.Alert("This is an alert", color="primary"), dbc.Alert("Danger", color="danger"), ] ) dis = DjangoDash("DjangoSessionState", add_bootstrap_links=True) dis.layout = html.Div( [ dbc.Alert("This is an alert", id="base-alert", color="primary"), dbc.Alert(children="Danger", id="danger-alert", color="danger"), dbc.Button("Update session state", id="update-button", color="warning"), ] ) #pylint: ignore=unused-argument
TIME_GRAPH = DjangoDash("TimeVisualiser") TIME_GRAPH.layout = html.Div(children=[ html.H1(children="Se udviklingen af data over tid"), html.Div(children=""" Du kan enten vælge at se data akkummuleret over tid, eller et rullende gennemsnit over data'en"""), dcc.Graph( id="time-graph", figure=get_accumulated_figure(), style={"height": "600px"}, ), dcc.RadioItems( id="cum-or-avg", options=[ { "label": "Rullende gennemsnit", "value": "avg" }, { "label": "Akkummuleret værdier", "value": "cum" }, ], value="cum", labelStyle={"display": "block"}, style={"textAlign": "center"}, ), dcc.Interval(id="interval-component", interval=5 * 1000, n_intervals=0), ], )
app.layout = html.Div([ dash_table.DataTable( id='datatable-interactivity', columns=[{ "name": i, "id": i, "deletable": True, "selectable": True } for i in df.columns], data=df.to_dict('records'), editable=False, filter_action="native", sort_action="native", sort_mode="multiple", column_selectable="single", row_selectable="multiple", row_deletable=True, selected_columns=[], selected_rows=[], page_action="native", page_current=0, page_size=10, ), html.Br(), html.Br(), html.Br(), html.Br(), html.Div(id='datatable-interactivity-container') ])
def portefeuille_eth(request, adresse): adresse = adresse year = [2010, 2020] seuil = 0 user = EthUsers.get_user(adresse) x_data, y_data = EthUsers.get_transactions(adresse) fig = EthUsers.figure(x_data, y_data) plot_div = plot(fig, output_type='div', include_plotlyjs=False) external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('connexions', external_stylesheets=external_stylesheets) app.layout = html.Div([ html.Div([html.H1("User's exchanges")], style={ 'textAlign': "center", 'font': '1em "Fira Sans", sans-serif' }), html.Div(children=[ html.Div(children=[ html.Div(children=[ dcc.Markdown(d("""Choisissez un intervalle""")), dcc.RangeSlider(id='yearslider', min=2010, max=2020, step=1, value=[2010, 2020], marks={ 2010: { 'label': '2010' }, 2011: { 'label': '2011' }, 2012: { 'label': '2012' }, 2013: { 'label': '2013' }, 2014: { 'label': '2014' }, 2015: { 'label': '2015' }, 2016: { 'label': '2016' }, 2017: { 'label': '2017' }, 2018: { 'label': '2018' }, 2019: { 'label': '2019' }, 2020: { 'label': '2020' } }), html.Br(), html.Div(id='output-container-range-slider') ], style={ 'position': 'absolute', 'height': '8%', 'width': '56%', 'colors': '#CDA277', 'float': 'left', 'background': '#f0f0f0' }), html.Div(children=[ dcc.Markdown( d(""" Choisissez un seuil """)), dcc.Input(id="valeurinp", type="number", placeholder="veuillez inserer un seuil"), html.Div(id="output") ], style={ 'position': 'absolute', 'height': '8%', 'background': '#f0f0f0', 'float': 'right', 'width': '39%', 'margin-left': '8%', 'display': 'inline-block' }) ], style={ 'font': 'caption', 'text-align': 'center', 'margin-bottom': '2%' }), html.Div(children=[ dcc.Graph(id="graphe", figure=EthUsers.star_graph(year, adresse, seuil)) ], style={ 'width': '95%', 'border': '15px solid #f0f0f0', 'display': 'inline-block', 'margin-top': '9%' }) ]) ]) @app.callback(dash.dependencies.Output('graphe', 'figure'), [ dash.dependencies.Input('yearslider', 'value'), dash.dependencies.Input('valeurinp', 'value') ]) def update_output(value, valeurinp): YEAR = value SEUIL = valeurinp return EthUsers.star_graph(value, adresse, valeurinp) return render(request, 'ethereum/portefeuille_eth.html', { 'user': user, 'plot_div': plot_div })
text=y, textposition='auto', marker_color=colors )]) text_A = ('Campaign Overview: ' + str(total_attempted) + ' voters out of ' + str(total_ppl) + ' voters contacted. ' + str(total_ids) + " IDs. Keep up the hard work!") percent1 = (total_attempted / total_ppl) * 100 percent2 = (total_ids / total_attempted) * 100 text_B = ('Campaign Overview: ' + str(round(percent1, 2)) + '% of voters attempted, ' + str(round(percent2, 2)) + '% of attemped voters resulted in IDs.' ) fig.update_layout(title_text=text_B) app.layout = html.Div([ dcc.Graph(id="graph", figure=fig), ]) @app.callback(Output('graph', 'figure')) def display_value(value): x = [] for i in range(value): x.append(i) y = []
app.layout = html.Div( children=[ dcc.Dropdown(id='vehicle_data', value='', style={'display': 'none'}), # html.Div(id='graph_body') dcc.Tabs(id="dashboard_type", value='descriptive', children=[ dcc.Tab(label='Descriptive', value='descriptive', style=tab_style, selected_style=active_tab_style), dcc.Tab(label='Value', value='value', style=tab_style, selected_style=active_tab_style), ], style={ 'margin-left': '4px', 'margin-right': '50%' }), dcc.Loading(id="loading-1", children=[html.Div(id='content_body')], type='circle', color='#ac0404', style={'margin-top': '19%'}) ], style={ # 'width': '80%', # 'margin': 'auto', 'padding-top': '20px', })
app.layout = html.Div([ dcc.Graph(id='table-editing-simple-output', figure = {'layout' : {'height': 350, 'margin': {'l': 60, 'b': 30, 'r': 60, 't': 10}, 'yaxis': {'type': 'linear'}, 'xaxis': {'showgrid': False} }, 'data' : []#[go.Scatter({'x': [], 'y': []})] } ), dcc.Input(id='target_id', type='hidden', value=0), dcc.Input(id='target_redshift', type='hidden', value=0), dcc.Input(id='min-flux', type='hidden', value=0), dcc.Input(id='max-flux', type='hidden', value=0), dcc.Checklist( id='line-plotting-checklist', options=[{'label': 'Show line plotting interface', 'value': 'display'}], value='' ), html.Div( children=[], id='checked-rows', style={'display': 'none'} ), html.Div( children=[ dbc.Row([ dbc.Table( html.Tbody([ html.Tr([ html.Td( dbc.Table(table_body_one, bordered=True), ), html.Td( dbc.Table(table_body_two, bordered=True), ) ]), ]) ) ]) ], id='table-container-div', style={'display': 'none'} ) ])
submit_app.layout = html.Div(children=[ dash_table.DataTable( id="table_example", columns=([{ 'name': 'Number', 'id': 'Number' }] + [{ 'name': 'Adm No', 'id': 'Adm No', 'type': 'numeric' }, { 'name': 'Student Name', 'id': 'Student Name', 'type': 'text' }] + [{ 'name': sub, 'id': sub, 'type': 'numeric' } for sub in subjects]), data=[ dict(Model=i, **{subj: 0 for subj in subjects}) for i in range(1, 30) ], style_data={'whitespace': 'normal'}, style_table={ 'maxHeight': '600px', 'overflowY': 'scroll', }, style_cell={'whiteSpace': 'normal'}, style_cell_conditional=[ { 'if': { 'column_id': 'Student Name' }, 'width': '150px' }, { 'if': { 'row_index': 'odd' }, 'backgroundColor': 'rgb(248, 248, 248)' }, ], style_header={ 'backgroundColor': 'white', 'fontWeight': 'bold' }, editable=True, ), html.Button(id='submit-button', n_clicks=0, children="Done"), html.Div(id="output", children="Proceed to Submit form below"), ])
app.layout = html.Div( id="root", children=[ # Below here it is a sample body html.Div( id="header", children=[ html.Img(id="logo", src=app.get_asset_url("dash-logo.png")), html.H4(children="Rate of US Poison-Induced Deaths"), html.P( id="description", children= "† Deaths are classified using the International Classification of Diseases, \ Tenth Revision (ICD–10). Drug-poisoning deaths are defined as having ICD–10 underlying \ cause-of-death codes X40–X44 (unintentional), X60–X64 (suicide), X85 (homicide), or Y10–Y14 \ (undetermined intent).", ), ], ), html.Div( id="app-container", children=[ html.Div( id="left-column", children=[ html.Div( id="slider-container", children=[ html.P( id="slider-text", children= "Drag the slider to change the year:", ), dcc.Slider( id="years-slider", min=min(YEARS), max=max(YEARS), value=min(YEARS), marks={ str(year): { "label": str(year), "style": { "color": "#7fafdf" }, } for year in YEARS }, ), ], ), html.Div( id="heatmap-container", children=[ html.P( "Heatmap of age adjusted mortality rates \ from poisonings in year {0}".format(min(YEARS)), id="heatmap-title", ), dcc.Graph( id="county-choropleth", figure=dict( data=[ dict( lat=df_lat_lon["Latitude "], lon=df_lat_lon["Longitude"], text=df_lat_lon["Hover"], type="scattermapbox", ) ], layout=dict( mapbox=dict( layers=[], accesstoken=mapbox_access_token, style=mapbox_style, center=dict(lat=38.72490, lon=-95.61446), pitch=0, zoom=3.5, ), autosize=True, ), ), ), ], ), ], ), html.Div( id="graph-container", children=[ html.P(id="chart-selector", children="Select chart:"), dcc.Dropdown( options=[ { "label": "Histogram of total number of deaths (single year)", "value": "show_absolute_deaths_single_year", }, { "label": "Histogram of total number of deaths (1999-2016)", "value": "absolute_deaths_all_time", }, { "label": "Age-adjusted death rate (single year)", "value": "show_death_rate_single_year", }, { "label": "Trends in age-adjusted death rate (1999-2016)", "value": "death_rate_all_time", }, ], value="show_death_rate_single_year", id="chart-dropdown", ), dcc.Graph( id="selected-data", figure=dict( data=[dict(x=0, y=0)], layout=dict( paper_bgcolor="#F4F4F8", plot_bgcolor="#F4F4F8", autofill=True, margin=dict(t=75, r=50, b=100, l=50), ), ), ), ], ), ], ), html.Div( dcc.Graph( id="dcc_t_2", figure=dict( data=[ dict( lat=df_ca["lat"], lon=df_ca["lng"], type="scattermapbox", ) ], layout=dict( mapbox=dict( layers=[ { "below": 'traces', "sourcetype": "raster", "source": [ "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}" ] }, ], # style="dark", # style="white-bg", accesstoken=mapbox_access_token, # style="dark", center=dict(lat=49.883333, lon=-97.166667), pitch=0, zoom=3, ), autosize=True, margin={ "r": 0, "t": 0, "l": 0, "b": 0 }, ), ), ), ), html.Div(dcc.Slider( id="y-slider", min=min(YEARS_1), max=max(YEARS_1), value=min(YEARS_1), marks={ str(year): { "label": str(year), "style": { "color": "#7fafdf" }, } for year in YEARS_1 }, ), style={'padding': 50}), html.Div( id="gra-container", children=[ html.H4(children="Alberta"), dcc.Dropdown( options=[ { "label": "AB_Canola Dryland TOTAL ACREAGE(Single year)", "value": "dryland_total_single", }, { "label": "AB_Canola Dryland WEIGHTED AVERAGE YIELD(single year)", "value": "dryland_weight_single", }, { "label": "AB_Canola Dryland TOTAL ACREAGE(all year)", "value": "dryland_total_all", }, ], value="dryland_total_single", id="c-dropdown", ), html.H4(children="Manitoba"), dcc.Dropdown( options=[ { "label": "MB_Canola Dryland TOTAL ACREAGE(Single year)", "value": "canola_total_single", }, { "label": "MB_Canola Dryland WEIGHTED AVERAGE YIELD(single year)", "value": "canola_weight_single", }, { "label": "MB_Canola Dryland TOTAL ACREAGE(all year)", "value": "canola_total_all", }, ], value="canola_total_single", id="mb-dropdown", ), html.H1(children="AB 2014-2018 & MB 2006-2018"), dcc.Graph( id="s-data", figure=dict( data=[dict(x=0, y=0)], layout=dict( paper_bgcolor="#F4F4F8", plot_bgcolor="#F4F4F8", autofill=True, margin=dict(t=75, r=50, b=100, l=50), ), ), ), ]), html.Div( dcc.Graph( id="dcc_t_1", figure=dict( data=[ dict( lat=us_cities["lat"], lon=us_cities["lon"], # lat=df_lat_lon["Latitude "], # lon=df_lat_lon["Longitude"], # text=df_lat_lon["Hover"], type="scattermapbox", ) ], layout=dict( mapbox=dict( layers=[], style="dark", accesstoken=mapbox_access_token, # style="dark", center=dict(lat=38.72490, lon=-95.61446), pitch=0, zoom=3, ), autosize=True, # margin={"r":0,"t":0,"l":0,"b":0}, ), ), ), ), ], )
from dash.dependencies import Input, Output from datetime import datetime as dt from _alpaha_vatage_keys import api_key from alpha_vantage.techindicators import TechIndicators from alpha_vantage.timeseries import TimeSeries from django_plotly_dash import DjangoDash external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] # app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app = DjangoDash('datepicker', external_stylesheets=external_stylesheets) app.layout = html.Div([ dcc.DatePickerSingle( id='date-picker-range', date=dt(2019, 5, 3), ), html.Div(id='date-content') ]) api_key = api_key period = 60 ts = TimeSeries(key=api_key, output_format='pandas') @app.callback(Output('date-content', 'children'), [Input('date-picker-range', 'date')]) def render_content(date): data_ts = ts.get_daily(symbol='fb', outputsize='full') price_df = data_ts[0][period::] date = dt.strptime(date, '%Y-%m-%d')
'label': 'Day', 'value': 3600000 * 24 }, { 'label': 'Hour', 'value': 3600000 }, { 'label': '4 Hour', 'value': 3600000 * 4 }], value=3600000), html.Button('Submit', id='submit-val', n_clicks=0), html.Div([dcc.Markdown(id='hoverdata-text')]) ]) app.layout = layouto @app.callback(dash.dependencies.Output('hoverdata-text', 'children'), [dash.dependencies.Input('egraph', 'figure')]) def callback_stats(hoverData): return str(hoverData['data'][0]['xbins']) @app.callback(dash.dependencies.Output('egraph', 'figure'), [dash.dependencies.Input('date-pick', 'value')]) def ojala(child): df = pd.DataFrame(list(Cigar.objects.order_by('pub_date').values())) filt = df.loc[df['stopped'] == 1] df = pd.DataFrame(list(Cigar.objects.order_by('pub_date').values())) nofilt = df.loc[df['stopped'] == -1]
import plotly import numpy as np import requests import json app = DjangoDash('IBsY8wP289RJfUfs') app.title = 'P.Dashboard' app.layout = html.Div(children=[ html.H1(children='Application Sample'), html.Div(children='Plotly Dash App'), dcc.Graph(id='graph', figure={ 'data': [ { 'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'Sydney' }, { 'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'Melbourne' }, ], 'layout': { 'title': 'Data Graphs' } }) ])
HISTOGRAM_GRAPH.layout = html.Div(children=[ html.Div( header, style={ "display": "flex", "justifyContent": "space-between", "width": "80%", "margin": "auto", }, ), html.Div( [ html.Div(id="table"), dcc.Graph(id="indicator-graphic", ), ], style={ "width": "80%", "margin": "auto" }, ), html.Div( [ html.Div( [ html.H6( "Hold markøren over en søjle for at se information", style={ "width": "80%", "margin": "auto" }, ), html.Pre(id="hover-data"), ], style=styles["pre"], ), html.Div( [ html.H6( "Klik på en søjle for at se information", style={ "width": "80%", "margin": "auto" }, ), html.Pre(id="click-data"), ], style=styles["pre"], ), ], style={ "width": "80%", "display": "flex", "margin": "auto" }, ), ])
app.layout = html.Div([ html.Div([ dcc.DatePickerRange( id='data-picker-range', min_date_allowed=dt(2018, 1, 1), max_date_allowed=dt.today(), ), dcc.Dropdown( id='dropdown-one', options=select_corpuses, # value=select_corpuses[0]['value'], # persisted_props = ['None'], clearable=True, ), dcc.Dropdown( id='dropdown-two', options=select_test, # value=select_test[0]['value'], clearable=True, placeholder='Всі зони', ), dcc.Dropdown( id='dropdown-three', # options= select_test if (2+2==4) else select_test, # value='None', clearable=True, placeholder='Всі агрегати', ), html.Div(id='testone'), ]), ])