def test_confirm(self): app = dash.Dash(__name__) app.layout = html.Div( [ html.Button(id="button", children="Send confirm", n_clicks=0), dcc.ConfirmDialog(id="confirm", message="Please confirm."), html.Div(id="confirmed"), ] ) @app.callback(Output("confirm", "displayed"), [Input("button", "n_clicks")]) def on_click_confirm(n_clicks): if n_clicks: return True self._test_confirm(app, "ConfirmDialog")
def mask_content(self): return [ dcc.Markdown(""" To mask a region, click on the **Select region button** then select your region on the graph. To mask one of the trace, click on it (selected trace are highlihted. Confirmation will be asked before saving the masks. """, className='markdown'), # roi x limits dbc.InputGroup([ dbc.InputGroupAddon("Masks", id='masks', addon_type="prepend"), dbc.Button("Select region", color="secondary", outline=True, size='sm', id='select-mask') ], size='sm'), html.Pre(children="No masks selected", id='text-data'), dcc.ConfirmDialog(id='confirm-mask', ), ]
def init_tab_2(): return dcc.Tab(label='Add Transaction', className = 'custom-tab', selected_className="custom-tab--selected", children = [ html.Div([ html.Div(id='input_section', children = tab2_build_inputs()), # using the init funciton earlier to build input field # confirm dialog with button for both add and clear action, only shown when button is clicked html.Div([ # confirm dialog with button for add transaction action dcc.ConfirmDialogProvider( children = html.Button( 'Add',style = {'margin-left': 30, 'width': 100,'text-align': 'center'} ), id = 'add', message = 'Are you sure to continue?'), # confirm dialog with button for clear input action dcc.ConfirmDialogProvider( children = html.Button( 'Clear',style = {'width': 100, 'text-align': 'center'} ), id = 'reset', message = 'Are you sure to clear all inputs?'), ],style = {'padding': 10, 'display': 'flex', 'flex-direction': 'row-reverse','width': '90%',}), # confirm dialog, only display when add button is clicked without all required inputs filled in # serve to prevent trades with missing information to be added html.Div( dcc.ConfirmDialog(id = 'confirm', message = 'Please fill in all * fields!') ), # dash table for display of trades accoridng to the user selected html.Div(id = 'tab2_table', # initializa to display the trades of the first user in the user list children = tab2_build_table(trade_table, user_list[0]), style = {'height': 400,'margin': 'auto', 'width': '90%', 'margin-top': 15}) ], style = {'margin-left': 30, 'margin-right': 30, 'margin-top': 20, 'margin-bottom': 30 }) ])
def sample_report(page_n, lasso_selected, data_store): page_n = int(page_n) #json_data = StringIO(data_store) data = pd.DataFrame.from_dict(data_store) if lasso_selected != "" and lasso_selected is not None: lasso = lasso_selected.split(",") # lasso first data = data[data._id.isin(lasso)] if len(data) == 0: return [] samples = data["_id"] data = data.sort_values(["species", "name"]) skips = PAGESIZE * (page_n) page = data[skips:skips + PAGESIZE] page = import_data.add_sample_runs(page) max_page = len(samples) // PAGESIZE page_species = page["species"].unique().tolist() # We need to have fake radio buttons with the same ids to account for times # when not all PAGESIZE samples are shown and are not taking the ids required by the callback html_fake_radio_buttons = html.Div([ dcc.RadioItems(options=[{ 'label': '', 'value': 'nosample' }], value='noaction', id="sample-radio-{}".format(n_sample)) for n_sample in range(len(page), PAGESIZE) ], style={"display": "none"}) return [ html.H4("Page {} of {}".format(page_n + 1, max_page + 1)), html.Div(children_sample_list_report(page)), html_fake_radio_buttons, admin.html_qc_expert_form(), html.H4("Page {} of {}".format(page_n + 1, max_page + 1)), html.Div(id="placeholder0", style={"display": "none"}), dcc.ConfirmDialog( id='qc-confirm', message='Are you sure you want to send sample feedback?', ) ]
def on_click(n_clicks): if n_clicks: return dcc.ConfirmDialog(displayed=True, id='confirm', key='confirm-{}'.format(time.time()), message='Please confirm.')
dcc.Link(html.Button(id='back-button', children='Back', style={'marginLeft':'5%','marginRight':'5%', 'float':'left'}), href='/'), dcc.ConfirmDialogProvider( children=html.Button( 'submit', style={'marginLeft':'5%','marginRight':'5%', 'float':'left'} ), id='submit-button', message='Document will be added to DataCentral. Are you sure you want to submit?' ), dcc.ConfirmDialog( id = 'submit-state', message = 'Please fill in all required fields' ), dcc.ConfirmDialog( id = 'submit-confirm', message = 'Document has been successfully submitted' ) ], style={'marginLeft':'5%', 'marginRight':'5%', 'width': '40%'}) ], style={'overflow': 'hidden', 'padding': '20px'}) ]) ########################
type='default'), html.H4('How would you rate the quality of the audio ?'), dcc.Slider( id='rating', max=5, min=1, step=1, marks={i: f'{i}' for i in range(1, 6)}, ), # dcc.Graph(id="waveform", figure=fig), html.Div(html.Button('Rate', id='rate-button', n_clicks=0)), html.H4("Please put a rating up here!", id='rating-message'), dcc.ConfirmDialog( id='confirm', message= "Too many words (>50) or too little (<10) may effect the quality of the audio, continue at your own risk ^^'" ), # html.A(children=[html.Img(src='https://cdn.buymeacoffee.com/buttons/default-orange.png',alt="Buy Me Coffee",height="41",width="174")],href='https://www.buymeacoffee.com/OthmaneJ'), ], style={ 'textAlign': 'center', 'marginRight': '100px', 'marginLeft': '100px', 'marginTop': '50px', 'marginBottom': '50px' }) # Set picture of celebrity @app.callback(dash.dependencies.Output('celebrity_img', 'src'),
from dash.dependencies import Input, Output import dash_core_components as dcc import dash_html_components as html from app import app server = app.server from apps import world, country external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.layout = html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content'), dcc.ConfirmDialog( id='confirm', message='Danger danger! Are you sure you want to continue?') ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/country': return country.layout else: return world.layout if __name__ == '__main__': app.run_server()
def get_account_elements(self): return [ dcc.Location(id="settings-url", refresh=True), html.H5( f"Permissions: {current_user.permissions.name.replace('_', ' + ')}" ), html.Hr(), html.Br(), html.H5("Change username"), html.Hr(), dbc.Button( "Change username", n_clicks=0, id="settings-change-username", color="secondary", ), dcc.ConfirmDialog( id="settings-confirm-change-username", message="Are you sure you want to change your username? " "This could have unintended consequences.", ), dbc.Modal( [ dbc.ModalHeader("Change username"), dbc.ModalBody( dbc.Form( [ dbc.FormGroup( [ dbc.Label("Enter new username"), dbc.Input( value=current_user.username, type="text", id="settings-new-username", ), dbc.FormFeedback( id="settings-new-username-invalid-feedback", valid=False, ), ], row=False, ) ] ) ), dbc.ModalFooter( dbc.Button( "Save", id="settings-save-new-username", className="ml-auto", disabled=True, ) ), ], id="settings-change-username-modal", ), html.Br(), html.Br(), html.Br(), html.H5("Delete account"), html.Hr(), html.P("Permanently delete your account."), dbc.Button( "Delete account", n_clicks=0, id="settings-delete-account", color="danger", ), dcc.ConfirmDialog( id="settings-confirm-delete-account", message="Are you sure you want to delete your account? " "This cannot be undone.", ), ]
html.Pre(id='show-algorithm', style=styles['pre']) ], style={'height': '400px'}), # html.Div(dcc.Input(id='input-on-play', type='text')), # html.Div(id='container-button-basic', # children='Enter a value and press play') ]) ]), # ###########################################middle graph component html.Div( className="eight columns", children=[ dcc.ConfirmDialog( id='confirm', message='Game over, restart?', ), dcc.Graph(id="my-graph", figure=utils.next_tic(0, 1)) ], ), # ########################################right side two output component html.Div( className="two columns", children=[ # html.Div( # className='twelve columns', # children=[ # dcc.Markdown(d(""" # **Hover Data** #
"FlowCell","Index1","Index2","LIMS IUS SWID","LaneClusterPF","LaneClusterRaw", "LaneNumber","LaneYield","QualityScoreSum","ReadNumber","Run","RunNumber","SampleID", "SampleName","SampleNumberReads","SampleYield","TrimmedBases","Yield","YieldQ30" pruned_unknown_hidden holds json split format of "unknown" columns: "Count","LaneNumber","Index1","Index2","Run","LIMS IUS SWID """ layout = html.Div(children=[ # This element doesn't work correctly in a multi-app context. Left in code for further work # ToDO # https://jira.oicr.on.ca/browse/GR-776 and https://jira.oicr.on.ca/browse/GR-777 core.Location(id=ids["bcl2fastq_url"], refresh=False), core.ConfirmDialog( id=ids["error"], message=('You have input an incorrect run. Click either "Ok" or ' '"Cancel" to return to the most recent run.'), ), core.Dropdown( id=ids["run_select"], # Options is concantenated string versions of all_runs. options=[{ "label": r, "value": r } for r in all_runs], value=all_runs[0], clearable=False, ), core.Graph(id=ids["known_index_bar"]), html.Div([ html.Div(
editable=True ), html.Button(id='button_adjustment', children='Apply', n_clicks=0) ], style={'columnCount': 2}), dash_table.DataTable(id='table_adjustment', data=pd.DataFrame([['Strategy 0 / Instrument 0']+['']*3], columns=['Id', 'Function', 'Argument', 'Dates']).to_dict('records'), columns=[{'id': i, 'name': i} for i in ['Id', 'Function', 'Argument', 'Dates']], hidden_columns=['Dates'], style_cell={'textAlign': 'left'}, editable=False, row_deletable=True, ), html.H1(), html.H4(children='Run', style={'color': '#0073aa'}), html.Button(id='button_portfolio', children='Run Portfolio'), dcc.ConfirmDialog(id='select_before_id'), dcc.ConfirmDialog(id='confirm'), dcc.ConfirmDialog(id='upload_file_adjustment'), dcc.Textarea(id='current_function_adjustment', style={'display': 'none'}), dcc.Textarea(id='state_function_adjustment', style={'display': 'none'}), html.Div(id='store_adjustment', style={'display': 'none'}) ]) trade_layout = html.Div([html.H1(), html.H4(children='Portfolio', style={'color': '#0073aa'}), dash_table.DataTable(id='portfolio_trades'), dcc.Loading(id="loading_table_trades", children=[html.Div(id="output_table_trades")], type="default"), html.H1(), dcc.Loading(id="loading_trade_instrument", children=[html.Div(id="output_trade_instrument")], type="default"), html.H1() ])
# add subject button add_subject_button = html.Button( children='Add a subject record', id='add-subject-button', n_clicks=0, style=button_style) add_subject_modal = component_utils.create_modal( subject.Subject, 'subject', include_parts=True, dropdown_fields=['sex', 'subject_strain'], mode='add' ) # deletion confirm dialogue delete_subject_confirm = dcc.ConfirmDialog( id='delete-subject-confirm', message='Are you sure you want to delete the record?', ), delete_subject_button = html.Button( children='Delete the current record', id='delete-subject-button', n_clicks=0, style=button_style ) update_subject_button = html.Button( children='Update the current record', id='update-subject-button', n_clicks=0, style=button_style ) # -------- Pop up window with update table and message ------
def on_click(n_clicks): if n_clicks: return dcc.ConfirmDialog( displayed=True, id="confirm", message="Please confirm." )
'borderRadius': '5px', 'textAlign': 'center', 'margin': '10px' }, multiple=True, contents=[], filename=[] ), dcc.Markdown(id= 'error_list', children=[]), #"* Error 1 \n* Error 2" html.Button('Continue', id='btn-continue', style={'font-family' : 'helvetica', 'textAlign' : 'center'}, disabled=False) ]) main_layout = html.Div([ dcc.ConfirmDialog( id='error_message', message="There are no solutions that fulfill all restrictions", ), html.H2("Clustering-based Pareto-Front exploration", style={'text-align': 'center'}), dcc.Slider( id="slider_nivel", min=0, max=10, value=0, step=1, marks={0: '0'}, # Ponerlo como default, luego se irá sobreescribiendo, no hace falta la variable global. included=False, disabled=True ), html.Div([ html.Div([
"textAlign": "center", "margin": "10px" }, multiple=True), html.Br(), html.Div([ html.Div([html.H3("Uploaded Files"), html.Ul(id="file-list")], style={ "width": "20%", "display": "inline-block" }), html.Div([ dcc.ConfirmDialog( id='confirm-clear-input', message= ("Are you sure you would like to delete all uploads ? \n This " "action cannot be reversed"), submit_n_clicks=0), html.Button( id='clear-input-button', children="Clear Uploads", n_clicks=0) ], style={ "width": "50%", "display": "inline-block" }) ], style={"width": "80"}), html.Br(), html.Div(id="button-container", children=[ html.Button(children="Click to Begin Calculations",
html.Div(id='date-picker-container', className='date_picker_container'), dcc.Loading(children=html.Div(id='search-bar', className='search_bar'), ), html.Div(id='black-list-of-words', className='black_list_words'), html.Div(id='proceed-to-step3', className='proceed_to_step3'), html.P(id='unmatched-words-notice', className='unmatched_words'), html.Div(id='step3-text', className='step3_block'), html.Div(id='filtered-queries', className='query_list_tbs'), html.Div(id='proceed-to-step4', className='proceed_to_step4'), html.Div(id='step4-text', className='step4_block'), html.Div(children=[ dcc.Loading(children=[html.Div(id='submission-loading')], type='circle'), html.P(id='please-wait-txt', className='submission_loading') ]), dcc.ConfirmDialog( id='confirm', message='Are you sure you want to submit the data?', ) ], id='root') def parse_data(data_json, filename): _, content = data_json.split(',') decoded = base64.b64decode(content) try: if filename.endswith('.json'): global searched_data data = json.load(io.StringIO(decoded.decode('utf-8'))) searched_data = [e for e in data if e['title'][0] == 'S'] return searched_data else:
def warning_message(id, message): return html.Div([ dcc.ConfirmDialog(id=id, message=message), html.Div(id=f"output-{id}") ])
def get_users_elements(self): return [ dbc.Form( [ dbc.FormGroup( [ dbc.Label("Select a user to manage their account"), dcc.Dropdown( id="settings-select-user", options=[ {"label": u, "value": u} for u in UserService().iter_usernames() if u != current_user.username ], ), ] ) ] ), html.Br(), html.H5("Set permissions"), html.Hr(), dbc.Label("Permissions"), dbc.Form( [ dbc.FormGroup( [ dcc.Dropdown( id="settings-set-user-permissions", options=[ { "label": p.name.replace("_", " + "), "value": p.name, } for p in Permissions ], disabled=True, ), dbc.Button( "Save", n_clicks=0, id="settings-save-user-permissions", disabled=True, color="primary", ), ], className="mr-3", ) ], inline=True, ), html.Br(), html.Br(), html.H5("Delete account"), html.Hr(), html.P("Permanently delete their account."), dbc.Button( "Delete account", n_clicks=0, id="settings-delete-user-account", color="danger", disabled=True, ), dcc.ConfirmDialog( id="settings-confirm-delete-user-account", message="Are you sure you want to delete their account? " "This cannot be undone.", ), ]
[ "Press \"GO\" to recolor the graph. Recoloring follows two rules:", dcc.Markdown(""" 1. If a vertex has at least one adjacent black neighbor, recolor it black. 2. Otherwise, recolor it white. """), ], id = "instructions", ) ], id = "turn-stuff" ), # Error dialog for load problems dcc.ConfirmDialog( id = "error-dialog", displayed = False, message = "" ), # Graph loading via path input html.Hr(), html.Div( dcc.Input( id = "file-path-input-box", placeholder = "Enter path to graph file...", type = "text", value = "", style = { "padding-bottom": "1px" } )
# for timeline cleanDate = pd.to_datetime(df['Date'], errors='coerce') df.loc[:, 'Month'] = cleanDate.dt.month df.loc[:, 'Year'] = cleanDate.dt.year alert = "" # Layout app.layout = html.Div(children=[ html.Div( className='container-fluid', children=[ html.Div( dcc.ConfirmDialog( id='confirm', message='Your selected range has no data! Try again!', displayed=False), ), html.Div(id='output-confirm'), html.Div( className='row', children=[ html.Div( # checklist className='col-sm-4', children=[ html.Div(className='container-fuild', children=[ html.Button('Select All', id='selectAll', n_clicks_timestamp=0), html.Button('Clear',
style={ 'overflow': 'scroll', 'height': '60vh' }) ], className='message is-link', style={'width': '100%'}) ], className='tile is-8 search_input'), ], id='showPanel', className='tile is-ancestor', style={'display': 'none'}), visdcc.Run_js(id='crawlScript'), visdcc.Run_js(id='crawlScript1'), dcc.ConfirmDialog(id='confirm', message='已爬取过该用户,是否重新爬取?'), html.Div([ html.Div('', className='tile is-4'), html.Div([ html.Div( [ html.Header([ html.Div('查询结果', id='crawled-title', className='card-header-title') ], className='card-header'), html.Div([ html.Div([ html.Div('时间', id='crawledLasttime'), html.Br(),
], style={"display": "inline-block"}), html.Button("Download Data", n_clicks=0, className="button-primary", id="download_button"), html.Div(className="tab"), html.Button("Generate Result", n_clicks=0, className="button-primary", id="display_button"), dcc.Loading( [dcc.Store(id="raw_data"), dcc.Store(id="hist_vol")]), dcc.ConfirmDialog( id='tkr_error', message='', ), ]), # right column, output results html.Div( className="nine columns", children=[ #html.Div("Right Column"), dcc.Loading(html.Div(id="result")), ]) ]) @app.callback([
def page2_result(content, date, ret, vol, df_comp): if type(content) == str: return dcc.ConfirmDialog(id='confirm', message=content) table_title1 = [html.Thead(html.Tr([html.H4("리밸런싱 전/후 비교")]))] table_title2 = [html.Thead(html.Tr([html.H4("자산별 구성 및 운용성과")]))] table_title3 = [html.Thead(html.Tr([html.H4("리밸런싱 과거 내역")]))] table_header_comp = [ html.Thead(html.Tr([html.Th(col) for col in list(df_comp.columns)])) ] print('table_header_comp is : {}'.format(table_header_comp)) print('in page2_result, df_comp is', df_comp) rows = df_comp.values.tolist() # print(rows) comp_row = list() for row in rows: temp = [html.Td(record) for record in row] comp_row.extend([html.Tr(temp)]) print('in page2_result, comp_row is', comp_row) table_header = [ html.Thead( html.Tr([ html.Th("시점"), html.Th("Cash"), html.Th("Equity"), html.Th("Fixed Income"), html.Th("Alternative"), html.Th("Total"), html.Th("누적수익률(%)"), html.Th("변동성(%)") ])) ] # print('content.date: {}'.format(content.date)) # print('date: {}'.format(date)) latest_content = content.loc[content.date == date, :] latest_content.value = to_numeric(latest_content.value) print('content.columns: {}'.format(content.columns)) print('content.shape: {}'.format(content.shape)) print('content: {}'.format(content)) # print('----------------------------') # print('latest_content.shape: {}'.format(latest_content.shape)) # print('latest_content.columns: {}'.format(latest_content.columns)) # print('latest_content: {}'.format(latest_content)) # print('latest_content.date: {}, date: {}'.format(latest_content.date, date)) # print('latest_content[latest_content[asset_class] == Cash][value]: {}'.format(latest_content.loc[latest_content.asset_class == 'Cash', 'value'])) summary = latest_content.loc[:, ['asset_class', 'value']].groupby( 'asset_class').sum().reset_index() total = summary.value.sum() total = '{:,}'.format(int(total)) latest_content.value = latest_content.value.astype(int).apply( lambda x: "{:,}".format(x)) summary.value = summary.value.astype(int).apply( lambda x: "{:,}".format(x)) row1 = html.Tr([ html.Td("현재"), html.Td(summary.loc[summary.asset_class == 'Cash', 'value']), html.Td(summary.loc[summary.asset_class == 'Equity', 'value']), html.Td(summary.loc[summary.asset_class == 'Fixed Income', 'value']), html.Td(summary.loc[summary.asset_class == 'Alternative', 'value']), html.Td(total), html.Td('{:.1f}'.format(float(ret) * 100)), html.Td('{:.1f}'.format(float(vol) * 100)) ]) # print('----page2_result에서 상세내역 찍기 시작---') # result = user.closeData(select, name=user.name, date=user.date, choice=False) # print('content 첫줄 보면..') # print(content.iloc[:1, :3]) # 과거 내역(detail) 중 리밸런싱이 발생한 날짜의 레코드만 result = content.loc[content.original == 'Rebal', :] print('content.shape: {}, result.shape: {}'.format( content.shape, result.shape)) # RA자문 탭에서 상세잔고내역의 컬럼명/컬럼순서 변경 result = result.loc[:, [ 'date', 'name', 'itemname', 'price', 'quantity', 'value', 'wt', 'original' ]] result.date = to_datetime(result.date).dt.strftime('%Y-%m-%d') result.loc[:, ['price', 'quantity', 'value' ]] = result.loc[:, ['price', 'quantity', 'value']].astype( float).astype(int).applymap(lambda x: "{:,}".format(x)) result.loc[:, ['wt']] = (result.loc[:, ['wt']].astype(float) * 100).applymap(lambda x: "{:.1f}".format(x)) result = result.rename( columns={ 'date': '날짜', 'name': '이름', 'itemname': '종목명', 'price': '종가', 'quantity': '보유수량', 'value': '평가금액', 'wt': '비중(%)', 'original': '납입금여부' }) table_header_detail = [ html.Thead(html.Tr([html.Th(col) for col in list(result.columns)])) ] rows = result.values.tolist() # print(rows) table_row = list() for row in rows: temp = [html.Td(data) for data in row] table_row.extend([html.Tr(temp)]) print('table_header_detail is {}'.format(table_header_detail)) print('in page2_result, table_row is', table_row) return html.Div([ dbc.Table(table_title1, bordered=False, style={ 'margin-top': '18px', 'margin-bottom': '10px', 'text-align': 'left', 'paddingLeft': 12 }), dbc.Table(table_header_comp + [html.Tbody(comp_row)], bordered=True, style={ 'margin-top': '18px', 'margin-bottom': '10px', 'text-align': 'left', 'paddingLeft': 12 }), dbc.Table(table_title2, bordered=False, style={ 'margin-top': '18px', 'margin-bottom': '10px', 'text-align': 'left', 'paddingLeft': 12 }), dbc.Table(table_header + [html.Tbody([row1])], bordered=True, style={ 'margin-top': '18px', 'margin-bottom': '10px', 'text-align': 'left', 'paddingLeft': 12 }), dbc.Table(table_title3, bordered=False, style={ 'margin-top': '18px', 'margin-bottom': '10px', 'text-align': 'left', 'paddingLeft': 12 }), dbc.Table(table_header_detail + [html.Tbody(table_row)], bordered=True, style={ 'margin-top': '18px', 'margin-bottom': '10px', 'text-align': 'left', 'paddingLeft': 12 }) ])
filename = "~/projects/Dash-by-Plotly/Dataset/social_capital.csv.gz" data_path = Path(filename) df = pd.read_csv(data_path, compression='gzip') # Data from U.S. Congress, Joint Economic Committee, Social Capital Project. df.drop(['Alt FIPS Code', 'FIPS Code', 'State Abbreviation'], axis=1, inplace=True) app = dash.Dash(__name__) # ------------------------------------------------------------------------ app.layout = html.Div([ dcc.ConfirmDialog( id='confirm-dialog', displayed=False, message='Please choose Dropdown variables!', ), html.H1("Scatter Matrix of USA Social Capital Project", style={'textAlign': 'center'}), dcc.Dropdown(id='my-dropdown', options=[{ 'label': s, 'value': s } for s in df.columns], value=[ "% children 4+ hours on electronic device past week", "% children read to every day past week", "% children 4+ hours television past week", "% women currently married" ],
import dash_core_components as dcc import dash_html_components as html from app import app server = app.server from apps import world, country external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.layout = html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content') ]) app.layout = html.Div([ dcc.ConfirmDialog( id='confirm', ) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/country': return country.layout else: return world.layout if __name__ == '__main__': app.run_server()
page_options = [] for key in all_pages: page_options.append({'label': 'Page ' + key, 'value': key}) else: current_page = 0 all_pages = {} page_options = [{'label': 'No Pages Available', 'value': '-1'}] app.layout = html.Div(style={'width':"100%"}, children=[ dcc.Markdown(children="# Book Image Reader: A Web App for Reading Books in Picture Formats (jpeg, png etc.)"), # dcc.Markdown(id="status", children="#### Status: No Images Loaded"), dcc.ConfirmDialog( id='confirm', message='Page Loading into App Completed!!!' ), dcc.Upload( id='upload-data', children=html.Div([ html.A('Click Here to Select File') ]), style={ 'height': '60px', 'lineHeight': '60px', 'borderWidth': '1px', 'borderStyle': 'dashed', 'borderRadius': '5px', 'textAlign': 'center', 'margin': '10px'
def serve_layout(preview) -> html.Div: """ :param preview: The preview DataFrame of all available experiments in result path. :return: App layout """ preview = preview.reset_index().rename(columns={'index': 'code'}) preview['id'] = preview['code'] stores = html.Div([ dcc.Store(id='store_session_id', storage_type='session', data=str(uuid.uuid4())), dcc.Store(id='store_dashboard_config', storage_type='session', data=dict()), dcc.Store(id='store_active_graph', storage_type='session', data=[]), dcc.Store(id='store_favorites', storage_type='local'), # Wrapping store_loaded_experiment in a loading component causes a loading screen whenever # store_loaded_experiment is changed. dcc.Loading(dcc.Store(id='store_loaded_experiment', storage_type='session', data=-1), id='loading_experiment', fullscreen=True, type='cube'), # SIGNALS dcc.Store(id='signal_add_graph', storage_type='memory'), dcc.Store(id='signal_update_graphs', storage_type='memory'), dcc.Store(id='signal_resize', storage_type='memory'), dcc.Store(id='signal_move', storage_type='memory'), dcc.Store(id='signal_pre_settings', storage_type='memory'), dcc.Store(id='signal_update_settings', storage_type='memory'), dcc.Store(id='signal_delete', storage_type='memory'), dcc.Store(id='signal_load_favorite', storage_type='memory'), ]) overlay = html.Div(id='experiment_overlay', className='side side-right', children=html.Div( id='experiment_overlay_content', children=[ html.H5('Select Experiment'), dash_table.DataTable( id='table_experiment_preview', sort_action="native", row_selectable='single', style_data={ 'whiteSpace': 'normal', 'height': 'auto' }, style_table={ 'maxHeight': '80vh', 'overflowY': 'scroll', 'overflowX': 'scroll' }, style_header={'padding': '10px'}, style_cell={'textAlign': 'left'}, columns=[{ 'name': i, 'id': i } for i in preview.columns.drop('id')], data=preview.to_dict('records'), ), daq.BooleanSwitch( on=False, id='load_predefined_dashboard', label="Load predefined dashboard", labelPosition="top", style=dict(marginTop='30px')) ])) navbar = html.Div( id='navbar', children=[ html.Button('Filter', id='btn_toggle_filter'), html.Div( id='favorites_container', children=[ html.Button('Favorites', id='btn_favorites'), html.Div( id='favorites_content', children=[ html.Div( id='favorites_table', children=[ dash_table.DataTable( id='table_favorites', sort_action="native", row_selectable='single', style_data={ 'whiteSpace': 'normal', 'height': 'auto', }, style_table={'overflow': 'auto'}, style_cell={'textAlign': 'left'}, style_header={'padding': '10px'}, columns=[{ 'name': 'ID', 'id': 'fav_id' }, { 'name': 'Experiment Code', 'id': 'code' }, { 'name': 'Creation Time', 'id': 't_create' }, { 'name': 'Comment', 'id': 'comment' }, { 'name': 'Number Graphs', 'id': 'number_graphs' }], ), html.Button( 'Load', id='btn_load_favorite', style=dict( margin='10px 2.5px 10px 0')), html.Button( 'Load (append)', id='btn_load_append_favorite', style=dict( margin='10px 2.5px 10px 2.5px')), html.Button( 'Delete', id='btn_remove_favorite', style=dict( margin='10px 0 10px 2.5px')), ]), dcc.Input(id='input_favorite_comment', autoComplete='off', type='text', placeholder='Enter Comment', style=dict(width='100%', marginTop='10px')), html.Button('Add current Dashboard', id='btn_add_favorite', style=dict(marginTop='10px')), html.A('Download Favorites', id='download_favorites', className='button', style=dict(display='inline-block', margin='10px 0 0 5px', width='auto'), download="", href="", target="_blank"), dcc.Upload( id='upload_favorites', children=html.Div([ 'Upload Favorites - ', html.A('Select File') ]), style={ 'width': '100%', 'height': '35px', 'lineHeight': '35px', 'border': 'dashed 1px grey', 'borderRadius': '5px', 'textAlign': 'center', 'marginTop': '10px', }, multiple=False, max_size=10000, ), dcc.ConfirmDialog( id='upload_alert', message= 'Please upload JSON file for current experiment.', ), ]) ]), html.Button('Select Experiment', id='btn_toggle_experiment_overlay'), html.Button('Experiment Info', id='btn_experiment_info'), html.Button('Activate all', id='btn_activate_all'), html.Button('Close all active', id='btn_close_all_active'), html.Button(id='btn_test', style=dict(display='none')), html.Div(id='add_graph_container', children=[ html.Button('Add Graph', id='add_graph_button'), html.Div(id='add_graph_content', children=[ html.Button('Add empty Graph', id='btn_add_empty'), html.Button('Duplicate Graph', id='btn_duplicate_graph'), html.Button('Add preset Graph', id='btn_add_preset'), html.Button('Add Statistics Table', id='btn_add_table'), html.Button('Investigate Q1', id='btn_add_investigate_q1'), ]) ]), html.Div(id='div_workflow_name', style=dict(display='inline')), html.Button('Settings', id='btn_toggle_settings', style=dict(float='right', marginRight='20px')), ]) filter_side = html.Div( id='filter_side', className='sidenav', children=[ html.Div([ html.H5('DBMS / Connections', id='heading_table_dbms'), dash_table.DataTable( id='table_dbms', style_data={ 'whiteSpace': 'normal', 'height': 'auto' }, row_selectable='multi', style_cell={'textAlign': 'left'}, page_action='none', style_table={ 'maxHeight': '350px', 'overflow': 'scroll', }, ), html.Div(id='btn_select_all_connections', className='icon-btn'), html.Div(id='btn_deselect_all_connections', className='icon-btn'), html.Div(id='btn_connection_info', className='icon-btn'), html.H5('Filter Connections'), html.Label("DBMS"), dcc.Dropdown(id='dropdown_dbms', multi=True), html.Label("Node"), dcc.Dropdown(id='dropdown_node', multi=True), html.Label("Client"), dcc.Dropdown(id='dropdown_client', multi=True), html.Label("GPU"), dcc.Dropdown(id='dropdown_gpu', multi=True), html.Label("CPU"), dcc.Dropdown( id='dropdown_cpu', multi=True, ), html.Button('Apply Filter', id='btn_apply_filter'), ]), html.Div([ html.H5('Queries'), dash_table.DataTable( id='table_query', style_data={ 'whiteSpace': 'normal', 'height': 'auto' }, row_selectable='single', style_cell={'textAlign': 'left'}, # fixed_rows={'headers': True, 'data': 0}, page_action='none', style_table={ 'maxHeight': '300px', # TODO max height 'overflowY': 'scroll', 'overflowX': 'scroll' }, ), html.Div(id='btn_deselect_query', className='icon-btn'), html.Div(id='btn_query_info', className='icon-btn'), ]) ]) settings_side = html.Div( id='settings_side', className='sidenav', children=[ html.Div(id='parent_radio_preset_graph', children=[ dcc.RadioItems( id='radio_preset_graph', options=[ dict(label='Heatmap Errors', value='heatmap_errors'), dict(label='Heatmap Warnings', value='heatmap_warnings'), dict(label='Heatmap Result Set Size', value='heatmap_result_set_size'), dict(label='Heatmap Total Time', value='heatmap_total_time'), dict(label='Heatmap Latency Run', value='heatmap_latency_run'), dict(label='Heatmap Throughput Run', value='heatmap_throughput_run'), dict(label='Heatmap Timer Run Factor', value='heatmap_timer_run_factor'), dict(label='Bar Chart Run drill-down', value='barchart_run_drill'), dict(label='Bar Chart Ingestion Time', value='barchart_ingestion_time') ]) ]), html.Div( id='div_graph_settings', children=[ html.H5('Settings', id='heading_settings'), html.Label('Type', id='label_type'), dcc.Dropdown( id='dd_type', options=[ { 'label': x, 'value': x } for x in ['timer', 'latency', 'throughput', 'monitoring'] ], ), html.Label('Name', id='label_name'), dcc.Dropdown(id='dd_name', ), html.Label('Aggregate Run', id='label_query_aggregate'), dcc.Dropdown( id='dd_query_aggregate', options=[{ 'label': x, 'value': x } for x in [ 'factor', 'Mean', 'Std Dev', 'cv [%]', 'Median', 'iqr', 'qcod [%]', 'Min', 'Max', 'Geo', '1st', 'Last', 'Sum', 'P25', 'P75', 'P90', 'P95' ]], ), html.Label('Aggregate Query', id='label_total_aggregate'), dcc.Dropdown( id='dd_total_aggregate', options=[{ 'label': x, 'value': x } for x in [ 'factor', 'Mean', 'Std Dev', 'cv [%]', 'Median', 'iqr', 'qcod [%]', 'Min', 'Max', 'Geo', '1st', 'Last', 'Sum', 'P95', 'P25', 'P75', 'P90', 'P95' ]], ), html.Label('Aggregate Config', id='label_connection_aggregate'), dcc.Dropdown( id='dd_connection_aggregate', options=[{ 'label': x, 'value': x } for x in [ 'factor', 'Mean', 'Std Dev', 'cv [%]', 'Median', 'iqr', 'qcod [%]', 'Min', 'Max', 'Geo', '1st', 'Last', 'Sum', 'P95', 'P25', 'P75', 'P90', 'P95' ]], ), html.Label('Graph Type', id='label_graph_type'), dcc.Dropdown( id='dd_graph_type', options=[{ 'label': x, 'value': x } for x in [ 'Heatmap', 'Boxplot', 'Line Chart', 'Histogram', 'Bar Chart', 'Table Measures', 'Table Statistics', 'Preset' ]]), html.Div(id='div_warmup', children=[ html.Label('Number of warmup runs', htmlFor='slider_warmup', id='label_slider_warmup'), dcc.Slider( id='slider_warmup', min=0, max=10, step=1, value=0, marks={x: str(x) for x in range(11)}, ) ]), html.Div(id='div_cooldown', children=[ html.Label('Number of cooldown runs', htmlFor='slider_cooldown', id='label_slider_cooldown'), dcc.Slider( id='slider_cooldown', min=0, max=10, step=1, value=0, marks={x: str(x) for x in range(11)}, ) ]), html.Label('X-Axis', id='label_graph_xaxis'), dcc.Dropdown(id='dd_graph_xaxis', options=[{ 'label': x, 'value': x } for x in ['Query', 'Connection']], value='Query', clearable=False), html.Label('Color by', id='label_graph_colorby'), dcc.Dropdown( id='dd_graph_colorby', options=[{ 'label': x, 'value': x } for x in [ 'DBMS', 'Node', 'Script', 'CPU Limit', 'Client', 'GPU', 'CPU' ]], ), html.Label('Boxpoints', id='label_boxpoints'), dcc.Dropdown( id='dd_boxpoints', options=[ { 'label': x.capitalize(), 'value': x } for x in ["False", "all", "outliers", "suspectedoutliers"] ], value="False"), html.Label('Sort', id='label_order'), dcc.Dropdown(id='dd_order', options=[{ 'label': x.capitalize(), 'value': x } for x in [ "trace", "category ascending", "category descending", "total ascending", "total descending", "min ascending", "min descending", "max ascending", "max descending", "sum ascending", "sum descending", "mean ascending", "mean descending", "median ascending", "median descending" ]], value='default', clearable=False), dcc.Checklist(id='checklist_annotate', options=[{ 'label': 'Annotate', 'value': 'annotate' }], value=[]), html.Div(id='div_input_gridColumn_all', children=[ html.Label('Grid Columns: '), dcc.Input( id='input_gridColumn_all', type="number", className='', min=3, max=12, step=3, debounce=True, ) ]), html.Div(id='div_input_gridRow_all', children=[ html.Label('Grid Rows: '), dcc.Input( id='input_gridRow_all', type="number", className='', min=1, max=3, step=1, debounce=True, ), ]), ]), ]) graph_grid = html.Div(id='graph_grid', children=[]) content = html.Div(id='content', children=[filter_side, settings_side, graph_grid]) modal = html.Div(id='info_modal', children=[ html.Span(id='span_close_modal', children='x'), html.Div(id='info_modal_body', children=[]) ]) layout = html.Div([ stores, overlay, navbar, content, modal, ]) return layout
def init_tab_2(): return dcc.Tab(label='Add Transaction', className = 'custom-tab', selected_className="custom-tab--selected", children = [ html.Div([ #html.H3('Add Transaction'), html.Div([ html.Div([ html.Div( dcc.Input(id = 'user', className = "text_input", type = 'text', placeholder = 'User'), className = "three columns"), html.Div( dcc.Input(id = 'portfolio', className = "text_input", type = 'text', placeholder = 'Portfolio'), className = "three columns"), html.Div( dcc.DatePickerSingle( id = 'timestamp', placeholder = 'Date'), className = "three columns", style = {'width': 270}), html.Div( dcc.Input(id = 'type', type = 'text', className = "text_input", placeholder = 'Type of Trade'), className = "three columns"), ], className = "twelve columns", style = {'padding': 10}), html.Div([ html.Div( dcc.Input(id = 'product', type = 'text', className = "text_input", placeholder = 'Product'), className = "three columns"), html.Div( dcc.Dropdown(id='direction', options=[{'label': 'Long', 'value': 'Long'}, {'label': 'Short', 'value': 'Short'}], placeholder = 'Direction'), className = "three columns", style = {'width': 200, 'margin-right': 65}), html.Div( dcc.Input(id = 'price', type = 'number', className = "text_input", placeholder = 'Price'), className = "three columns", style = {'margin-right': 5}), html.Div( dcc.Input(id = 'size', type = 'number', className = "text_input", placeholder = 'Size/Notional'), className = "three columns"), ], className = "twelve columns", style = {'padding': 10}), html.Div([ html.Div( dcc.Input(id = 'tenor', type = 'text', className = "text_input", placeholder = 'Tenor'), className = "three columns"), html.Div( dcc.Input(id = 'risk', type = 'number', className = "text_input", placeholder = 'Amount to Risk'), className = "three columns"), html.Div( dcc.Input(id = 'timeframe', type = 'text', className = "text_input", placeholder = 'Timeframe'), className = "three columns") ], className = "twelve columns", style = {'padding': 10}), html.Div([ dcc.Input(id = 'strategy', type = 'text', placeholder = 'Strategy Type', style = {'width': 800, 'height': 100}) ], className = "twelve columns", style = {'padding': 10}), ], style = {'margin-left': 120}), html.Div([ dcc.ConfirmDialogProvider( children = html.Button( 'Add', ), id = 'add', message = 'Are you sure to continue?'), # dcc.ConfirmDialogProvider( # children = html.Button( # 'Reset', # ), # id = 'reset', # message = 'Are you sure to clear all inputs?'), ],style = {'padding': 10,'margin-right': 200, 'display': 'flex', 'flex-direction': 'row-reverse'}), html.Div( dcc.ConfirmDialog(id = 'confirm', message = 'There are blank fields!') ), html.Div(id = 'tab2_table', children = tab2_build_table(trade_table, user_list[0]), style = {'height': 400,'margin-left': 50, 'width': 1200, 'margin-top': 15}) ], style = {'margin-left': 30, 'margin-top': 20, 'margin-bottom': 30}) ])
slider=dcc.RangeSlider(id="range-slider",min=list_of_marks[0],max=list_of_marks[-1],marks=marks, step=step,value=[min_val,max_val],allowCross=False) # Initialise the app app = dash.Dash(__name__, meta_tags=[{"name": "viewport", "content": "width=device-width, initial-scale=1"}]) app.title="Bunker Analytics" server=app.server # Define the app app.layout = html.Div("Bunker Dash") app.layout = html.Div(children=[dcc.ConfirmDialog(id='date-error',message='Wrong date range'), html.Div(id="main-header",className="container-row twelve columns", children=[ html.Div(id="header",className="div-header bg-navy",##Header children=header_dropdown()) ]), html.Div(id="main-rank",className='container three columns', children=[ html.Div(id="ranking-container",children=ranking() ,className='div-ranking bg-navy'), html.Div(id="age-container",children=barges(),className='div-ops bg-navy') ]), html.Div(id="main-map",className="container five columns", children=[ html.Div(id="map-container",children=bunker_map(),##Map className='div-for-maps bg-navy'),