role="button", ), className="lead", ) ], fluid=True, ) ], fluid=True, #style=JUMBOTRON_STYLE, #style={'background': 'url(https://pixabay.com/get/51e3d4464a54b108feda8460da2932771637d8e65b5171_1920.jpg)'} ) link_input = dbc.FormGroup(dbc.Container([ dbc.Label( "Enter a link and press submit", className="col-form-label col-form-label-lg", ), dbc.Row([ html.Div([ dbc.Input(placeholder="Your link", type="text", bs_size="lg"), dbc.FormText(""), ]), html.Div([ html.Button('Submit', className='btn btn-info', type="submit"), ]), ]) ]), id="link_input") file_input = html.Div( html.Div([ html.Div([
} color_scales = { "is_cloudy": px.colors.sequential.Blues, "temp": px.colors.sequential.Bluered } navbar = dbc.NavbarSimple(children=[], brand="Home Assignment", brand_href="#", color="primary", dark=True, fixed="top") dropdown = dbc.FormGroup([ html.Div("dummy", className="mt-5"), dbc.Label("Color base", html_for="color-base", className="mt-2"), dcc.Dropdown(id='color-base', options=[{ 'label': v, 'value': k } for k, v in available_indicators.items()], value='temp', clearable=False), ]) year_slider = dbc.FormGroup([ dbc.Label("Select year range", html_for="year-slider"), dcc.RangeSlider(id='year-slider', min=min(years), max=max(years), value=[min(years), max(years)],
def dashMain(): # todo: allow to load any csv dfMaster = loadCsv() # get columns to make a stat table (list of columns) statsDf = pd.DataFrame(columns=['idx', 'stat']) statsDf['idx'] = [i for i in range(len(statList.keys()))] statsDf['stat'] = [x for x in statList.keys()] plotTypeList = [ 'Scatter', 'Histogram', 'Histogram + Box Plot', 'Cumulative Histogram', 'Strip Plot' ] # todo: add this as param to __init__ # todo: implement 'None', in particular in getMean() groupByList = ['File Number', 'analysisname', 'Region', 'Sex', 'Condition'] colorByList = ['None', 'analysisname', 'Region', 'Sex', 'Condition'] # todo: add as a parameter to __init__ defaultDict = { 'plotType': 'Scatter', 'groupBy': 'Region', 'colorBy': 'Region', 'xDefaultRow': 2, # todo: need to grab this index from preferred stat in statList 'yDefaultRow': 0, } # initial tables xStat = 'thresholdVal' yStat = 'spikeFreq_hz' xMeanDf = getMean(dfMaster, groupByList, xStat) yMeanDf = getMean(dfMaster, groupByList, yStat) # todo: add same colors to all plots #colors = px.colors.qualitative.Dark24 #print(' colors:', colors) # # moved to app.py ''' myStyles = 'assets/myStyle.css' # this is crap, no layout #external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] # can't use dark themes external_stylesheets = [dbc.themes.BOOTSTRAP, myStyles] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) server = app.server ''' # a control panel div with dropdowns, checkbox, and radio tmpControlDiv = html.Div( [ dbc.Row( [ dbc.Col(html.Label('Plot Type'), width="auto"), dbc.Col( makeDropdown('plot-type-dropdown', plotTypeList, defaultDict['plotType']) #, width=3 ), ], #],no_gutters=True, ), # row dbc.Row( [ dbc.Col(html.Label('Group By'), width="auto"), dbc.Col( makeDropdown('group-by-dropdown', groupByList, defaultDict['groupBy']) #, width=3 ), ], #],no_gutters=True, ), # row dbc.Row( [ dbc.Col(html.Label('Color By'), width="auto"), dbc.Col( makeDropdown('color-by-dropdown', colorByList, defaultDict['colorBy']) #, width=3 ), ], #],no_gutters=True, ), # row dbc.Label(''), dbc.Row( [ dbc.Col(html.Label('Plot Data'), width="auto"), dbc.Col( makeCheckList('plot-options-check-list', ['Raw', 'Mean'], 'Raw') #, width=3 ), ], #],no_gutters=True, ), # row dbc.Label(''), dbc.Row( [ dbc.Col(html.Label('Update Plot'), width="auto"), dbc.Col( makeRadio('update-plot-radio', ['Left', 'Right'], 'Left') #, width=3 ), ], #],no_gutters=True, ), # row ], className='container', style={'font-size': '12px'}) #, style={'fontColor': 'blue'}) #]) # outerdiv ## ## boxBorder = "0px black solid" tmpOneRow2 = html.Div( # outer div [ dbc.Row( [ dbc.Col( html.Div([html.Label('Parameters'), tmpControlDiv] #,style={'font-size': '11px'} ) # div , width=4, style={"border": boxBorder}), dbc.Col( html.Div([ html.Label('X-Stat'), makeTable('x-stat-table', statsDf, height=180, defaultRow=defaultDict['xDefaultRow']) ]) # div , width=4, style={"border": boxBorder}), # col dbc.Col( html.Div([ html.Label('Y-Stat'), makeTable('y-stat-table', statsDf, height=180, defaultRow=defaultDict['yDefaultRow']) ]) # div , width=4, style={"border": boxBorder}), # col #dbc.Col( # html.Div([ # #html.Label('Color By'), # dcc.Graph(id="scatter-plot") # ]) # ,width=6,style={"border":boxBorder}), # col ], #],no_gutters=True, ), # row dbc.Row( [ dbc.Col( html.Div([ #html.Label('Color By'), dcc.Graph(id="scatter-plot-left") ]), width=6, style={"border": boxBorder}), # col dbc.Col( html.Div([ #html.Label('Color By'), dcc.Graph(id="scatter-plot-right") ]), width=6, style={"border": boxBorder}), # col ], ), # row ], className='container') # outerdiv tmpOneRow3 = html.Div( # outer div [ dbc.Row( [ dbc.Col( html.Div([ html.Label('X Group By'), #makeTable('x-mean-table', xMeanDf, height=300, row_selectable=None), makeTable('x-mean-table', xMeanDf, height=300, row_selectable='multi'), ]), width=6, style={"border": boxBorder}), # col dbc.Col( html.Div([ html.Label('Y Group By'), makeTable('y-mean-table', yMeanDf, height=300, row_selectable=None), ]) # div , width=6, style={"border": boxBorder}), # col ], ), # row ], className='container') # outerdiv indexLayout = html.Div([ tmpOneRow2, # controls and x/y stat tables tmpOneRow3, # plots ]) app.layout = html.Div([ # i don't understand this. This is hidden but allows # callback to go to a different page? #dcc.Location(id='url', refresh=False), dcc.Location(id='url'), mynavbar.myNavBar, #tmpOneRow, # controls #tmpControlDiv, # single div for all controls v2 # was this #tmpOneRow2, # controls and x/y stat tables #tmpOneRow3, # plots html.Div(id='page-content'), # working on two page app ]) #, style={'columnCount': 3}) # # callbacks # @app.callback(dash.dependencies.Output("page-content", "children"), [dash.dependencies.Input('url', 'pathname')]) def displayPageCallback(pathname): print('displayPageCallback() pathname:', pathname) if pathname == "/": return indexLayout elif pathname == '/uploadPage': return uploadpage.uploadPageLayout else: # If the user tries to reach a different page, return a 404 message return dbc.Jumbotron([ html.H1("404: Not found", className="text-danger"), html.Hr(), html.P(f"The pathname {pathname} was not recognised..."), ]) @app.callback( [ Output("scatter-plot-left", "figure"), Output("scatter-plot-right", "figure"), Output("x-mean-table", "data"), Output("y-mean-table", "data"), ], [ Input('plot-type-dropdown', 'value'), Input('x-stat-table', 'selected_rows'), Input('y-stat-table', 'selected_rows'), Input('group-by-dropdown', 'value'), Input('color-by-dropdown', 'value'), Input('plot-options-check-list', 'value'), # (raw, mean) State('update-plot-radio', 'value'), # (left, right) ]) def f(plotType, xRow, yRow, groupBy, colorBy, plotOptions, plotLeftRight): """ Parameters: plotType: xRow,yRow: [list] groupBy: plotOptions: List of options that are checked, like ['plot raw', 'plot mean'] plotLeftRight: plot to either the left or right plot """ print('=== f()') print(' plotType:', plotType) print(' xRow:', xRow) print(' yRow:', yRow) print(' groupBy:', groupBy) print(' colorBy:', colorBy) print(' plotOptions:', plotOptions) print(' plotLeftRight:', plotLeftRight) print(' 1) defaultDict:', defaultDict) defaultDict['xDefaultRow'] = xRow[0] defaultDict['yDefaultRow'] = yRow[0] print(' 2) defaultDict:', defaultDict) # use context ctx to determine who triggered callback ctx = dash.callback_context if not ctx.triggered: idTriggered = 'No clicks yet' else: idTriggered = ctx.triggered[0]['prop_id'].split('.')[0] print(' idTriggered:', idTriggered) # x if xRow is None: xRow = 0 else: xRow = xRow[0] xStat = statsDf.iloc[xRow]['stat'] print(' x-stat-table Input:', xStat) # y if yRow is None: yRow = 0 else: yRow = yRow[0] yStat = statsDf.iloc[yRow]['stat'] print(' y-stat-table Input:', yStat) # convertt human to actual column xStatCol = statList[xStat]['yStat'] yStatCol = statList[yStat]['yStat'] # todo: append xMeanDf/yMeanDf to tables ''' xMeanDf = getMean(dfMaster, groupByList, xStatCol) yMeanDf = getMean(dfMaster, groupByList, yStatCol) xMean = xMeanDf['mean'].tolist() yMean = yMeanDf['mean'].tolist() xSem = xMeanDf['sem'].tolist() ySem = yMeanDf['sem'].tolist() # plot mean as different colors, this does not work ??? # color of mean, tricky meanColor = xMeanDf[groupBy].tolist() meanColorList = [colors[idx] for idx, x in enumerate(meanColor)] ''' fig = go.Figure() #plotRaw = plotOptions is not None and 'plot raw' in plotOptions #plotMean = plotOptions is not None and 'plot mean' in plotOptions plotRaw = plotOptions is not None and 'Raw' in plotOptions plotMean = plotOptions is not None and 'Mean' in plotOptions #plotType = 'Histogram + Boxplot' xAxisTitle = '' yAxisTitle = '' if plotType == 'Scatter': rawScatterList = plotScatter(dfMaster, xStatCol, yStatCol, groupBy, colorBy, plotRaw=plotRaw, plotMean=plotMean) # rawScatterList is a list of [scatter, mean) for rawScatter in rawScatterList: fig.add_trace(rawScatter) xAxisTitle = xStat yAxisTitle = yStat elif plotType in [ 'Histogram', 'Histogram + Box Plot', 'Cumulative Histogram' ]: doBoxPlotInset = plotType == 'Histogram + Box Plot' doCumulative = plotType == 'Cumulative Histogram' fig = plotHistogram(dfMaster, groupBy, yStatCol, doCumulative=doCumulative, doBoxPlotInset=doBoxPlotInset) #fig.add_trace(rawScatter) xAxisTitle = yStat yAxisTitle = 'Count' elif plotType == 'Strip Plot': doMeanSem = True fig = plotStripPlot(dfMaster, groupBy, yStatCol, doMeanSem=doMeanSem) # gives error #fig.update_layout(traceorder='normal') xAxisTitle = groupBy yAxisTitle = yStat fig.update_layout( #title="Plot Title", xaxis_title=xAxisTitle, yaxis_title=yAxisTitle, legend_title=groupBy, font=dict(family="Arial", size=12, color="Black"), margin=dict(l=20, r=20, t=20, b=20), ) # # use dash.no_update to update left/right and keep other the same # this works, but started using State for update-plot-radio #if idTriggered == 'update-plot-radio': # # don't update plot when use just click on plot radio left/right # print(' user selected left/right -->> no update') # return dash.no_update, dash.no_update, dash.no_update, dash.no_update if plotLeftRight == 'Left': # return fig, dash.no_update, xMeanDf.to_dict( 'records'), yMeanDf.to_dict('records') elif plotLeftRight == 'Right': # return dash.no_update, fig, xMeanDf.to_dict( 'records'), yMeanDf.to_dict('records')
dcc.Dropdown(id='xaxis-column') ], style={ 'width': '50%', 'float': 'right', 'display': 'inline-block' }) ]), dbc.Row([html.P("")]), dbc.Row([ dbc.Col( [ dbc.FormGroup([ dbc.Label( "Introduzca el nombre del eje de las ordenadas", style={ 'font-size': '130%', 'margin-top': '15px' }), dbc.Input(id='input-1-state', placeholder="Introduzca el nombre del eje Y", type="text", autoComplete='off'), ]), dbc.FormGroup([ dbc.Label( "Introduzca el nombre del eje de las abscisas", style={'font-size': '130%'}), dbc.Input(id='input-2-state', placeholder="Introduzca el nombre del eje X", type="text", autoComplete='off'),
import dash import dash_html_components as html import dash_bootstrap_components as dbc from dash.dependencies import Input, Output app = dash.Dash(__name__) app.layout = html.Div( dbc.Container(dbc.Form([ dbc.FormGroup([ dbc.Label("账号密码", html_for="password"), dbc.Input(id="password", placeholder="请输入密码", autoComplete='off'), dbc.FormText("密码至少同时包含大写字母、小写字母和数字!", color="secondary"), dbc.FormFeedback("密码格式满足要求!", valid=True), dbc.FormFeedback( "密码格式不满足要求!", valid=False, ), ]) ]), style={ 'margin-top': '200px', 'max-width': '400px' })) @app.callback([Output('password', 'valid'), Output('password', 'invalid')], Input('password', 'value')) def check_password_format(value): import re
], value=0, id="switches-indicators", switch=True, inline=True, ), ]), )), ), start_collapsed=True, ), html.B(), dbc.Card( dbc.CardBody( html.Div( [ dbc.Label("Advance Selling Options"), dbc.Checklist( options=[ { "label": "Trailing Immediate Buy", "value": "Trailing Immediate Buy", }, { "label": "Prevent Loss", "value": "Prevent Loss" }, ], value=[1], id="switches-advsell", switch=True, inline=True,
children=[ dbc.Button( "%2d" % (n, ), id={ "type": "label-class-button", "index": n }, style={"background-color": class_to_color(c)}, ) for n, c in enumerate(class_labels) ], ), html.Hr(), dbc.Form([ dbc.FormGroup([ dbc.Label( "Width of annotation paintbrush", html_for="stroke-width", ), # Slider for specifying stroke width dcc.Slider( id="stroke-width", min=0, max=6, step=0.1, value=DEFAULT_STROKE_WIDTH, ), ]), dbc.FormGroup([ html.H6( id="stroke-width-display", className="card-title", ),
'#ffcc00', # золотой header '#f5f2e8', # background main '#f8f3e3', # card main '#ffffff', # белый ] slider_day_values = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] slider_top_breweries_values = [5, 25, 50, 75, 100, 125, 150, 175, 200] controls = dbc.Card([ dbc.CardBody([ dbc.FormGroup([ dbc.Label("Временной период", style={ 'text-align': 'center', 'font-size': '100%', 'font-family': 'Proxima Nova Regular', 'text-transform': 'uppercase' }), dcc.Slider(id='slider-day', min=1, max=100, step=10, value=100, marks={i: i for i in slider_day_values}), ], style={'text-align': 'center'}), dbc.FormGroup([ dbc.Label("Количество пивоварен", style={
from dataanalytics.framework.file_utils import FileUtils from dataanalytics.framework.data_utils import DataUtils from dataanalytics.stats_linear_regression.linear_regression import LinearRegression from dataanalytics.stat_anova.anova import get_anova layout = html.Div(children=[ common.navbar("Regression Comparison"), html.Div([], style = {'padding': '30px'}), html.Br(), html.Div([ dbc.Button("Load Cleaned Files & Regression Model", color="info", id = 'rc-load-model', className="mr-4"), html.Br(), html.Hr(), html.H2('Model Comparision'), html.Div([ dbc.Label('Select Cleaned Data'), dcc.Dropdown( id = 'rc-select-data', options=[{'label':'', 'value':''}], multi=False ), html.Br(), ], style = {'width': '35%', 'display': 'inline-block'}), html.Br(), dbc.Button("Compare", color="primary", id = 'rc-compare', className="mr-4") ],style = {'margin': '10px'}), html.Div([], id = "rc-compare-display", style = {'margin': '10px'}), html.Div([], id = "rc-select-data-do-nothing"), html.Div([ html.Br(),
def select_model(model_name) -> list: """Populate the input data fields depending on the selected model. First triggered when a model is selected from the dropdown in the navbar. Loads an example MUSE model and populates the cards to edit input values. Does not run on startup. Args: model_name (str): The name of the selected model. From the dropdown. Returns: children (list): The children of the `input-values` Column. Contains: - A CardGroup for input values (technologies) - A CardGroup for agent values (objectives) - A Button to run the model using values within the CardGroup fields. """ # Do not run on startup if model_name is None: raise PreventUpdate model.select(model_name) return [ dbc.CardGroup([ dbc.Card( body=True, children=[ dbc.Label(sector.name.title(), size="lg"), dbc.Label( model.technodata[sector.name]["ProcessName"].iloc[-1], size="sm", ), ] + [ dbc.FormGroup( row=True, children=[ dbc.Label(technology, width=6), dbc.Col( dbc.Input( value=model.technodata[sector.name] [technology].iloc[-1], type="number", min=min(value_range), max=max(value_range), step=0.00000001, id={ "type": "input_value", "index": f"{sector.name}-{technology}", }, ), ), ], ) for technology, value_range in TECHNOLOGIES.items() ], ) for sector in model.sectors ], ), dbc.CardGroup([ dbc.Card( body=True, children=[ dbc.Label(agent["AgentShare"], size="lg"), dcc.Dropdown( options=[{ "label": objective, "value": objective } for objective in OBJECTIVES["Objective1"]], value=agent["Objective1"], id={ "type": "agent_value", "index": agent["AgentShare"], }, ), ], ) for index, agent in model.agents.iterrows() ], ), html.Br(), dbc.Button("Run Model", color="primary", id="run-button"), ]
import dash_html_components as html import dash_bootstrap_components as dbc import dash_core_components as dcc import dash_table import pandas as pd from datetime import date name_input = dbc.FormGroup([ dbc.Label("Name of the game", html_for="host_game_name"), dcc.Dropdown( id='demo-dropdown', options=[ { 'label': 'BANANAGRAMS', 'value': 1 }, { 'label': 'EXPLODING KITTENS', 'value': 2 }, { 'label': 'CARCASSONNE', 'value': 3 }, { 'label': 'CODENAMES', 'value': 4 }, { 'label': 'SETTLERS OF CATAN', 'value': 5
radio_elem = dbc.RadioItems(id='project-select', options=[ dict(label='1 day', value=1), dict(label='1 week', value=7), dict(label='2 weeks', value=14), dict(label='3 weeks', value=21), ], value=1, inline=True) input_elem = html.Div([ dbc.Form([ dbc.FormGroup( [ dbc.Label(f'Select {PROVINCE_NAME[INIT_COUNTRY].lower()}:'), dbc.Col( [dropdown_elem], width='True', id='province-select-div'), ], className='m-2', ) ]), dbc.Form([ dbc.FormGroup( [ dbc.Label('Show from:', className='mr-2'), datepicker_elem, ], className='m-2', ), dbc.FormGroup(
style={ 'width': '16px', 'height': '16px' }), color='primary', className='ml-2'), width=3, style={'padding-left': '0px'}) ], style={ 'margin-top': '4em', }), dbc.Row([ dbc.Label('Choose or add words', style={ 'color': 'white', 'margin-left': '1em' }), html.Div("", id='msgError', style={ 'color': 'red', 'text-transform': 'uppercase' }), html.Div( style={'margin-left': '2em'}, id='containerCheckList', children=dbc.Checklist( id='checklist', options=[{ 'label': el,
"yanchor": "middle", "xanchor": "right" } bill_join_df = pd.read_csv("data/bill_join_df.csv", index_col=0) bill_join_df.is_dutch = bill_join_df.is_dutch.map({True:'Dutch', False:'International'}) origin_list = bill_join_df.is_dutch.unique().tolist() origin_list.append('All') color_sequence = ["#f0ad4e", "#5bc0de", "#d9534f"] content = [ dbc.Row([ dbc.Col([ dbc.FormGroup([ dbc.Label("Country:"), dbc.Select( id='dutch', options=[{'label': key, 'value': key} for key in origin_list], value='All', disabled=True ) ]) ], width=4), dbc.Col([ dbc.FormGroup([ dbc.Label("Genre:"), dbc.Select( id="genres", options=[{'label': 'rock', 'value': 'rock'}], # TODO fix this with correct initial value list value='All',
dcc.Store(id='socket-val', data='/tmp/plasma'), dcc.Store(id='socket-connect-clicks', data=0), dcc.Store(id='previous-id'), dcc.Store(id='current-id'), dcc.Store(id='num_listing_rows', data=0), html.H1("Plasma Dash!"), dbc.Row( dbc.Col(dbc.Alert( id='alert-connection', children='Connecting...', color='info'), md=12)), dbc.Row( dbc.Col( dbc.Form([ dbc.FormGroup([ dbc.Label('Plasma Address', html_for='plasma-socket', className='mr-2'), dbc.Input( id='plasma-socket', value='/tmp/plasma', type='text') ], className='mr-3'), dbc.Button('Connect to Plasma', id='plasma-connect', color='primary', n_clicks=0) ], inline=True))), dbc.Row(dbc.Col(html.H2('Tables in Plasma')), className='mt-md-2'), dbc.Row([ dbc.Col([ dash_table.DataTable(
'', "100%", ] } ) return statistics layout = html.Div([ dbc.Row([html.H3("Parking Demand Prediction - Random Forest")], justify="center", align="center"), html.Br(), html.H4('Parameters:'), dbc.Row([ dbc.Col([ html.Div([ dbc.Label('Train/Test Size:'), html.Br(), dcc.Slider( id='pd2_date_slider', min=50, max=95, value=90, step=None, marks={i: {'label': str(i) + '% / ' + str(100 - i) + '%', 'style': {'color': '#000000'}} for i in range(50, 96, 5)}, ), ]), ], className='graph-grid'), ]), dbc.Row([ dbc.Col([
def instrument_input(app, orchestra): instruments = list(orchestra.keys()) dynamics = ['p', 'mf', 'f'] techs = ['normal'] notes = list(orchestra['violin']['normal']['mf'].keys()) id = '' instrument_group = dbc.FormGroup([ dbc.Label("Select instrument"), dbc.RadioItems( options=[{ "label": i, "value": i } for i in instruments], value='violin', id="instrument-input{}".format(id), inline=True, ), ], style={'display': 'inline-block'}) dynamic_group = dbc.FormGroup([ dbc.Label("Select dynamic"), dbc.RadioItems( options=[{ "label": i, "value": i } for i in dynamics], value='mf', id="dynamics-input{}".format(id), inline=True, ), ], style={'display': 'inline-block'}) target_group = html.Div([ dbc.Label("Set as target", style={'display': 'block'}), html.Div('orchestration', style={'display': 'inline-block'}), daq.BooleanSwitch( id='target-input{}'.format(id), on=False, color='red', style={'display': 'inline-block'}, ), html.Div('target', style={'display': 'inline-block'}) ], style={'display': 'inline-block'}) tech_group = dbc.FormGroup([ dbc.Label("Select technique"), dbc.RadioItems( options=[{ "label": i, "value": i } for i in techs], value='normal', id="techs-input{}".format(id), inline=True, ), ], style={'display': 'inline-block'}) note_group = dbc.FormGroup( [ dbc.Label("Select note"), dbc.RadioItems( options=[{ "label": pretty_midi.note_number_to_name(int(i)), "value": i } for i in notes], value=60, id="notes-input{}".format(id), inline=True, ), ], style={'display': 'inline-block'}, ) user_input = html.Div([ html.Div([ instrument_group, note_group, ]), html.Div([ dynamic_group, html.Hr(style={ 'width': '20px', 'display': 'inline-block' }), tech_group, html.Hr(style={ 'width': '20px', 'display': 'inline-block' }), target_group, ], ), ]) @app.callback([ Output('techs-input', 'options'), Output('notes-input', 'options'), Output('dynamics-input', 'options') ], ([Input('instrument-input', 'value'), Input('techs-input', 'value')])) def update_inputs(instrument, technique): techs = list(orchestra[instrument].keys()) techs = [{"label": i, "value": i} for i in techs] if technique in list(orchestra[instrument].keys()): tech = technique else: tech = list(orchestra[instrument].keys())[0] dyns = list(orchestra[instrument][tech].keys()) dyns = [{"label": i, "value": i} for i in dyns] notes = list(orchestra[instrument][tech]['p'].keys()) notes.sort() notes = [{ "label": pretty_midi.note_number_to_name(int(i)), "value": i } for i in notes] return [techs, notes, dyns] return user_input
layout = html.Div([ dcc.Markdown(""" ## I wonder When will my Transporter arrive ? ## Will he be free to take my offer ? """, style={ 'fontWeight': 'bold', 'color': 'grey' }), html.Div( [ html.Br(), html.Div([ dbc.Label("Departure", color="warning", style={'fontWeight': 'bold'}), dcc.Dropdown(id='depart', options=[{ 'label': i.upper(), 'value': i.lower() } for i in region], value=region[0]) ], style={ 'maxWidth': '400px', 'margin': 'auto' }), html.Div([ dbc.Label('Destination ', color="warning",
app = dash.Dash(__name__, external_stylesheets=['css/bootstrap.min.css']) app.layout = html.Div([ html.Br(), html.Br(), html.Br(), dbc.Container([ dbc.Row([ dbc.Col(dbc.Input(id='input-value1'), width=3), dbc.Col(html.P('+'), width=1), dbc.Col(dbc.Input(id='input-value2'), width=3), ], justify='start'), html.Hr(), dbc.Label(id='output-value') ]) ]) @app.callback(Output('output-value', 'children'), Input('input-value1', 'value'), Input('input-value2', 'value')) def input_to_output(input_value1, input_value2): try: return float(input_value1) + float(input_value2) except: return '请输入合法参数!' if __name__ == '__main__':
import dash_bootstrap_components as dbc import dash_html_components as html form = dbc.Form([ dbc.FormGroup( [ dbc.Label("Email", className="mr-2"), dbc.Input( id="email-input", type="email", placeholder="Enter email"), dbc.FormFeedback(valid=False, ), ], className="mr-3", ), html.Br(), dbc.FormGroup( [ dbc.Label("Password", className="mr-2"), dbc.Input(id="pass-input", type="password", placeholder="Enter password"), dbc.FormFeedback(valid=False, ), ], className="mr-3", ), html.Br(), html.Br(), dbc.Button("Log In", id="Log-button", color="primary"), ], inline=True, style={'margin-left': '480px'})
import dash_html_components as html import numpy as np import numpy_financial as npf import pandas as pd import plotly.graph_objects as go from dash.dependencies import Input, Output from dash.exceptions import PreventUpdate from app import app from config import stamp_duty_rates savings_card = dbc.Card([ dbc.CardHeader("Savings"), dbc.CardBody([ dbc.FormGroup([ dbc.Label("Total savings (£ ,000)"), dbc.Input(id="current-savings", value=50, type="number"), ]), dbc.FormGroup([ dbc.Label("Monthly savings rate (£)"), dbc.Input( id="saving-rate", value=500, step=10, type="number", ), ]), dbc.FormGroup([ dbc.Label("Savings interest (% annual)"), dbc.Input( id="savings-interest",
import dash_bootstrap_components as dbc from dash import html from .util import make_subheading input_ = html.Div([ make_subheading("Input", "input"), html.Div([ dbc.Label("Valid text input"), dbc.Input(type="text", valid=True), dbc.FormFeedback("That's a valid input!", type="valid"), ]), html.Div([ dbc.Label("Invalid text input"), dbc.Input(type="text", invalid=True), dbc.FormFeedback("That's an invalid input...", type="invalid"), ]), html.Div([ dbc.Label("What's the best language?"), dbc.Select( id="select", options=[ { "label": "Python", "value": "python" }, { "label": "R", "value": "r" }, {
suppress_callback_exceptions=False, external_scripts=["https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js", "https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js", "https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"] ) # 构建应用 app.layout = html.Div( dbc.Container( [ dbc.Form( [ # 英雄选择控件 dbc.FormGroup( [ dbc.Label('选择英雄名称:', html_for='hero_list'), dcc.Dropdown(id='hero_list', options=[ {'label': item['name'], 'value': item['heroId']} for item in hero_list['hero'] ]) ] ), # 查看内容选择空间 dbc.FormGroup( [ dbc.Label('选择要查看的内容:', html_for='hero_attributes'), dcc.Dropdown(id='hero_attributes', multi=True, options=[
'name': i, 'id': i } for i in df.columns], data=df.to_dict('rows'), style_table={ 'maxHeight': '10', 'overflowY': 'scroll' }, page_current=0, page_size=PAGE_SIZE, page_action='custom') graph = dcc.Graph(id='graph') checklist = dbc.FormGroup([ dbc.Label('Choose indicators', color='blue', size=20), dbc.Checklist( options=[{ 'label': 'Volume', 'value': 'Volume' }, { 'label': 'Bollinger Bands', 'value': 'Bollinger' }, { 'label': 'Stochastic Oscillator', 'value': 'Stoch' }], inline=True, style={ 'width': 5000, 'color': 'blue'
html.Br(), dbc.DatePickerRange( initial_visible_month=datetime(2018, 11, 8), min_date_allowed=datetime(2018, 11, 1), max_date_allowed=datetime(2018, 11, 30), disabled_days=SUNDAYS, ), html.Br(), html.H3("Dash Core Components"), dcc.DatePickerRange(initial_visible_month=datetime(2018, 1, 1)), html.Br(), html.H3("FormGroup"), dbc.Row([ dbc.Col( dbc.FormGroup([ dbc.Label("Type a thing"), dbc.Input(type="text", bs_size="sm"), ])), dbc.Col( dbc.FormGroup([ dbc.Label("Choose a date"), dbc.DatePickerSingle( initial_visible_month=datetime(2018, 1, 1), bs_size="sm", ), ]), width="auto", ), ]), html.Br(), dbc.Row([
df = pd.read_csv("Berlin_crimes.csv") app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) # https://bootswatch.com/default/ modal = html.Div( [ dbc.Button("Add comment", id="open"), dbc.Modal([ dbc.ModalHeader("All About Berlin"), dbc.ModalBody( dbc.Form( [ dbc.FormGroup( [ dbc.Label("Name", className="mr-2"), dbc.Input(type="text", placeholder="Enter your name"), ], className="mr-3", ), dbc.FormGroup( [ dbc.Label("Email", className="mr-2"), dbc.Input(type="email", placeholder="Enter email"), ], className="mr-3", ), dbc.FormGroup( [ dbc.Label("Comment", className="mr-2"), dbc.Input(type="text", placeholder="Enter comment"),
design = json.loads(response.text) # read in population response = requests.get( 'https://github.com/morrowmike/actuarial-tools/raw/master/pop_test.txt') population = json.loads(response.text) # read in av model claimant data #response = requests.get('https://raw.githubusercontent.com/morrowmike/actuarial-tools/master/AVSummarizedData.csv?token=ABGUBNS3XBWTLZTXCVRESLC6OS6HC') #clmnt_df = pd.read_csv(io.StringIO(response.decode('utf-8')),index_col=0) clmnt_df = pd.read_csv( 'https://github.com/morrowmike/actuarial-tools/raw/master/AVSummarizedData.csv', index_col=0) ### plan design form Ded_input = dbc.FormGroup( [ dbc.Label("Individual Deductible", width=8), dbc.Col(dbc.Input(type="text", id="input_ded", value=design['ind_ded']), width=4), ], row=True, ) Coin_input = dbc.FormGroup( [ dbc.Label("Member Coinsurance", width=8), dbc.Col(dbc.Input(type="text", id="input_coin", value=design['coin']), width=4), ], row=True, ) Moop_input = dbc.FormGroup(
from dash.dependencies import Input, Output, State from app import app from users_mgt import show_users, add_user from app import User layout = dbc.Container([ html.Br(), dbc.Container([ dcc.Location(id='urlUserAdmin', refresh=True), html.H3('Add New User'), html.Hr(), dbc.Row([ dbc.Col([ dbc.Label('Username: '******'newUsername', className='form-control', n_submit=0, style={ 'width': '90%' }, ), html.Br(), dbc.Label('Password: '******'newPwd1', type='password', className='form-control', n_submit=0,
def shap_dependence_layout(explainer, n_features=None, cats=True, **kwargs): cats_display = 'none' if explainer.cats is None else 'inline-block' return dbc.Container([ dbc.Row([ dbc.Col([ html.H3('Shap Summary'), dbc.Row([ dbc.Col([ dbc.Label("Depth:"), dcc.Dropdown( id='dependence-scatter-depth', options=[{ 'label': str(i + 1), 'value': i + 1 } for i in range( len(explainer.columns_ranked_by_shap(cats)))], value=min( n_features, len(explainer.columns_ranked_by_shap(cats)))) ], md=3), dbc.Col([ dbc.FormGroup([ dbc.Label("Summary Type"), dbc.RadioItems( options=[ { "label": "Aggregate", "value": "aggregate" }, { "label": "Detailed", "value": "detailed" }, ], value="aggregate", id="dependence-summary-type", inline=True, ), ]) ], md=3), dbc.Col([ dbc.Label("Grouping:"), dbc.FormGroup([ dbc.RadioButton(id='dependence-group-categoricals', className="form-check-input", checked=True), dbc.Label("Group Cats", html_for='dependence-group-categoricals', className="form-check-label"), ], check=True) ], md=3), ], form=True, justify="between"), dbc.Label('(Click on a dot to display dependece graph)'), dcc.Loading( id="loading-dependence-shap-summary", children=[dcc.Graph(id='dependence-shap-summary-graph')]) ], md=6), dbc.Col([ html.H3('Shap Dependence Plot'), dbc.Row([ dbc.Col([ html.Label('Plot dependence for column:'), dcc.Dropdown( id='dependence-col', options=[{ 'label': col, 'value': col } for col in explainer.columns_ranked_by_shap(cats) ], value=explainer.columns_ranked_by_shap(cats)[0]) ], md=5), dbc.Col([ html.Label('Color observation by column:'), dcc.Dropdown( id='dependence-color-col', options=[{ 'label': col, 'value': col } for col in explainer.columns_ranked_by_shap(cats) ], value=explainer.columns_ranked_by_shap(cats)[1]) ], md=5), dbc.Col([ html.Label('Highlight:'), dbc.Input(id='dependence-highlight-index', placeholder="Highlight index...", debounce=True) ], md=2) ], form=True), dcc.Loading(id="loading-dependence-graph", children=[dcc.Graph(id='dependence-graph')]), ], md=6), ]), ], fluid=True)
def render_content(tab, session): if tab == 'view-all-tab': content, message = get_event_details(session) style = {'color': 'red', 'fontSize': 14} if message is None else {'fontSize': 14} n_tickets_add_input = dbc.FormGroup([ dbc.Label("Additional No. Tickets", html_for="event-add-n_tickets", width=5), dbc.Col( dbc.Input( type="number", id="event-add-n_tickets-row", placeholder="Enter additional number of tickets for selected event", min=1 ), width=20) ], row=True) add_button = dbc.FormGroup([dbc.Button('Add', id='add-button')]) add_message = dbc.FormGroup(html.Div(id='add-message')) layout = html.Div([ dbc.Form([n_tickets_add_input, add_button, add_message]), html.Button('Refresh Events', id='refresh-button'), html.Div(id='event-error', children=message, style=style), dash_table.DataTable( id='events-table', columns=[ {"name": 'Event Identifier', "id": 'guid'}, {"name": 'Event Name', "id": 'name'}, {"name": 'Event Date', "id": 'date'}, {"name": 'Total Number of Tickets', "id": 'number_of_tickets'}, {"name": 'Number of Redeemed Tickets', "id": 'number_of_redeemed_tickets'}, ], data=content, row_selectable="single", filter_action="native", sort_action="native", page_action="native", page_current= 0, page_size= 25) ]) return layout elif tab == 'create-tab': name_input = dbc.FormGroup([ dbc.Label("Name", html_for="event-name", width=2), dbc.Col( dbc.Input( type="text", id="event-name-row", placeholder="Enter name of event", minLength=1, maxLength=255, ), width=10) ], row=True) date_input = dbc.FormGroup([ dbc.Label("Date", html_for="event-date", width=2), dbc.Col( dcc.DatePickerSingle( min_date_allowed=datetime.now().date(), id="event-date-row", initial_visible_month=datetime.now().date(), display_format='DD/MM/YYYY' ), width=10) ], row=True) n_tickets_input = dbc.FormGroup([ dbc.Label("Initial No. Tickets", html_for="event-n_tickets", width=2), dbc.Col( dbc.Input( type="number", id="event-n_tickets-row", placeholder="Enter initial numver of tickets of event", min=1 ), width=10) ], row=True) button = dbc.FormGroup([dbc.Button('Create', id='create-button')]) message = dbc.FormGroup(html.Div(id='create-message')) layout = dbc.Form([name_input, date_input, n_tickets_input, button, message]) return layout elif tab == 'ticket-tab': ticket_input = dbc.FormGroup([ dbc.Label("Ticket Identifier", html_for="event-ticket", width=2), dbc.Col( dbc.Input( type="text", id="event-ticket-row", placeholder="Enter identifier of a ticket", minLength=1, maxLength=50, ), width=10) ], row=True) status_button = dbc.FormGroup([dbc.Button('Check Status', id='status-button')]) status_message = dbc.Alert(id='status-message') layout = dbc.Form([ticket_input, status_button, status_message]) return layout