def get_schema(active_tab): if active_tab=="tab1": schema = html.Div( [ dbc.CardColumns([ generate_card(key,val) for key,val in sql_db.schema.items() ], ), ], className="mt-3", ) return schema
def Comparer_Base_layout(app): app.title = "KBO analysis" team_name = [ 'SSG', 'SK', 'KIA', '두산', '한화', 'LG', '삼성', '키움', '롯데', 'NC', 'KT' ] year = count_year() batter_name = [] pitcher_name = [] app.layout = html.Div([ baselayout, # 그래프 dbc.Container( [ dbc.Row( dbc.Col( dbc.Alert( "해당 분석은 한국프로야구단 공식 홈페이지인 KBO에서 스크래핑한 데이터를 바탕으로 진행되었습니다.", color="secondary", style={ 'margin-top': 80, 'margin-right': 10, 'margin-left': 10 }))), dbc.Row([ dbc.Col(children=[ dbc.Card( [ dbc.CardHeader("팀별 분석 비교"), dbc.CardBody( dcc.Checklist(id='team_name_select', value='', options=[{ 'label': i, 'value': i } for i in team_name], inputStyle={ 'margin-right': '2px', 'margin-left': '2px' }, labelStyle={ 'margin-right': '7px', 'margin-left': '7px' })), ], color="light", style={ 'width': "auto", 'margin-top': 20, 'margin-left': 10, 'margin-right': 10, 'margin-bottom': 20 }), dbc.CardColumns([ dbc.Card( [ dbc.CardHeader("연도별 승리 추세선"), dbc.CardBody( dcc.Graph(id='team_win_graph', hoverData={ 'points': [{ 'year': 'record' }] })), ], style={ 'width': "auto", 'margin-top': 20, 'margin-left': 10, 'margin-right': 10, 'margin-bottom': 20 }), dbc.Card( [ dbc.CardHeader("누적 월별 승률(%)"), dbc.CardBody( dcc.Graph(id='month_winprop_graph', hoverData={ 'points': [{ 'year': 'prop' }] })), ], style={ 'width': "auto", 'margin-top': 20, 'margin-left': 10, 'margin-right': 10, 'margin-bottom': 20 }) ]) ], xs=12, sm=12, md=6, lg=6), dbc.Col(children=[ dbc.Card( [ dbc.CardHeader("선수별 분석 비교"), dbc.CardBody( dcc.RadioItems( id="player", options=[{ 'label': '타자(Batter)', 'value': 'batter' }, { 'label': '투수(Pitcher)', 'value': 'pitcher' }], value='batter', inputStyle={'margin-right': '10px'}, labelStyle={'margin-right': '20px'})) ], color="light", style={ 'width': "auto", 'margin-top': 20, 'margin-left': 10, 'margin-right': 10, 'margin-bottom': 20 }), dbc.Card( [ dbc.CardBody( html.Div( [ dcc.Dropdown(id='name_list', options=[{ 'label': i, 'value': i } for i in batter_name ], value=[''], placeholder= "Typing player name", multi=True), dcc.Graph(id='graph2') ], style={ 'width': '100%', 'display': 'inline-block', 'font-size': '80%', 'margin-bottom': 80, 'margin-top': 5 })) ], style={ 'width': "auto", 'margin-top': 20, 'margin-left': 10, 'margin-right': 10, 'margin-bottom': 20 }) ], xs=12, sm=12, md=6, lg=6) ], no_gutters=True, justify="around"), ], id="graphs", style={ "width": "auto", 'margin-left': 210, 'color': None, "transition": "all .2s", "z-index": -1 }, fluid=True), # 사이드바 html.Div( [ html.Div( [ dbc.Nav([ html.P("Main", style={ 'color': '#7E8083', 'font-size': '80%' }), html.Li( dbc.Row([ dbc.Col(html.I( className="fas fa-balance-scale fa-2x", style={ 'color': '#FFFFFF', 'margin-top': 11, 'font-size': 17, 'margin-left': -1.5 }), width="auto"), dbc.Col( dbc.NavItem( dbc.NavLink( "Comparer", href= "http://127.0.0.1:5000/comparer/", id="comparer", style={ "color": "#FFFFFF", 'margin-left': -30 }))), dbc.Col(dbc.NavItem( dbc.NavLink( html.I( className= "fas fa-chevron-right fa-xs", style={ 'color': '#FFFFFF', 'margin-top': 8 }), href= "http://127.0.0.1:5000/comparer/") ), width=3) ])), html.Br(), html.Br(), html.Br(), html.P("Others", style={ 'color': '#7E8083', 'font-size': '80%' }), html.Li( dbc.Row([ dbc.Col(html.I( className="fas fa-project-diagram", style={ 'color': '#7E8083', 'margin-top': 12 }), width="auto"), dbc.Col( dbc.NavItem( dbc.NavLink( "Teams", href= "http://127.0.0.1:5000/teams/", id="teams", style={ "color": "#7E8083", 'margin-left': -30 }))), dbc.Col(dbc.NavItem( dbc.NavLink( html.I( className= "fas fa-chevron-right fa-xs", style={ 'color': '#7E8083', 'margin-top': 8 }), href="http://127.0.0.1:5000/teams/" )), width=3) ])), html.Li( dbc.Row([ dbc.Col(html.I( className="fas fa-chart-bar fa-2x", style={ 'color': '#7E8083', 'margin-top': 11, 'font-size': 20 }), width="auto"), dbc.Col( dbc.NavItem( dbc.NavLink( "Batters", href= "http://127.0.0.1:5000/batters/", id="batters", style={ "color": "#7E8083", 'margin-left': -30 }))), dbc.Col(dbc.NavItem( dbc.NavLink( html.I( className= "fas fa-chevron-right fa-xs", style={ 'color': '#7E8083', 'margin-top': 8 }), href= "http://127.0.0.1:5000/batters/")), width=3) ])), html.Li( dbc.Row([ dbc.Col(html.I( className="fas fa-table fa-2x", style={ 'color': '#7E8083', 'margin-top': 10, 'font-size': 18 }), width="auto"), dbc.Col( dbc.NavItem( dbc.NavLink( "Pitchers", href= "http://127.0.0.1:5000/pitchers/", id="pitchers", style={ "color": "#7E8083", 'margin-left': -28 }))), dbc.Col(dbc.NavItem( dbc.NavLink( html.I( className= "fas fa-chevron-right fa-xs", style={ 'color': '#7E8083', 'margin-top': 8 }), href= "http://127.0.0.1:5000/pitchers/") ), width=3) ])), ], vertical="md", horizontal='start', className="ml-auto"), ], id="sidebar", style={ "position": "fixed", "top": 55, "left": "-13rem", "bottom": 0, "width": "13rem", "padding": "2rem 1rem", "background-color": "#353A3F", "transition": "left .2s" }) ], id="side", style={ "position": "fixed", "top": 55, "left": "0", "bottom": 0, "width": 0, "background-color": "rgba(0, 0, 0, 0.5)", "transition": "left .2s", }) ]) @app.callback(Output("sidebar", "style"), Output("graphs", "style"), Output("side", "style"), [Input("sidebtn", "n_clicks")], [ State("sidebar", "style"), State("graphs", "style"), State("side", "style") ]) def toggle(n, style1, style2, style3): if n and style1['left'] == "-13rem" and style2['margin-left'] == 0: style1['left'] = 0 style2['margin-left'] = 210 style3['width'] = "100%" return style1, style2, style3 else: style1['left'] = "-13rem" style2['margin-left'] = 0 style3['width'] = 0 return style1, style2, style3 @app.callback(Output('team_win_graph', 'figure'), Output('month_winprop_graph', 'figure'), Input('team_name_select', 'value')) def update_output(value): fig1 = go.Figure() fig2 = go.Figure() for i in range(len(value)): year, prop, pred = team_win_table(value[i]) prop1 = month_win_prop(value[i]) fig1.add_trace(go.Scatter(x=year, y=prop, name=value[i])) fig2.add_trace( go.Bar(x=[3, 4, 5, 6, 7, 8, 9, 10], y=prop1, name=value[i], text=prop1)) fig2.update_traces(texttemplate='%{text:.2f}', textposition='outside') fig1.update_layout(margin=dict(l=0, r=0, t=0, b=0), template='plotly_white', height=300, xaxis=dict(tickmode='linear', dtick=1), legend=dict(orientation="h", yanchor="bottom", xanchor="center", x=0.5, y=-0.2)) fig2.update_layout(margin=dict(l=0, r=0, t=0, b=0), template='plotly_white', height=300, xaxis=dict(tickmode='linear', dtick=1), legend=dict(orientation="h", yanchor="bottom", xanchor="center", x=0.5, y=-0.2)) return fig1, fig2 @app.callback(Output('name_list', "options"), Output('name_list', "value"), Input('player', "value")) def batter_name_list(value): if value == 'pitcher': pitcher_name = pitcher_names() value = [''] options = [{'label': i, 'value': i} for i in pitcher_name] return options, value else: batter_name = batter_names() value = [''] options = [{'label': i, 'value': i} for i in batter_name] return options, value @app.callback(Output('graph2', "figure"), Input('name_list', "value"), Input('player', "value")) def batter_graph(value, value2): if value2 == 'batter': fig = make_subplots(rows=2, cols=1, vertical_spacing=0.1, specs=[[{ "type": "scatterpolar" }], [{ "type": "table" }]]) df = pd.DataFrame( columns=['NAME', 'AVG', 'OBP', 'SLG', 'ISO', 'EOBP']) if len(value) == 0: value = [''] for i in range(len(value)): scores = c_batter_yearly_base(value[i]) df.loc[i] = scores[-1] df.replace(scores[-1][0], value[i], inplace=True) fig.add_trace( go.Scatterpolar(r=list(scores[-1][1:]), opacity=0.7, theta=[ ' 평균타율(AVG) ', ' 출루율(OBP) ', ' 장타율(SGL) ', ' 순장타율(ISO) ', ' 순출루율(EOBP) ' ], fill='toself', name=value[i]), 1, 1) fig.add_trace( go.Table(header=dict(values=df.columns, height=32, fill_color='#6E757C', line_color='#6E757C', align='center', font=dict(color='white')), cells=dict(values=[ df.NAME, df.AVG, df.OBP, df.SLG, df.ISO, df.EOBP ], fill_color='white', line_color='#6E757C', font=dict(color='black'), align='center', height=32)), 2, 1) fig.update_layout(height=610, margin=dict(l=0, r=0, t=35, b=0), template=None, polar=dict(radialaxis=dict(visible=True, showticklabels=False, ticks=''), angularaxis=dict(showticklabels=True, ticks='', tickfont_size=13)), yaxis=dict(anchor="free", side="left", position=0.015), xaxis=dict(tickmode='linear', dtick=1), legend=dict(orientation="h", yanchor="bottom", y=1.05, xanchor="center", x=0.5)) else: fig = make_subplots(rows=2, cols=1, vertical_spacing=0.1, specs=[[{ "type": "scatterpolar" }], [{ "type": "table" }]]) df = pd.DataFrame( columns=['NAME', 'AVG', 'OBP', 'RA9', 'ERA', 'FIP']) if len(value) == 0: value = [''] for i in range(len(value)): scores, temp = c_pitcher_yearly_base(value[i]) df.loc[i] = scores[-1] df.replace(scores[-1][0], value[i], inplace=True) df.replace(float('inf'), 0, inplace=True) df = df.fillna(0) fig.add_trace( go.Scatterpolar(r=list(scores[-1][1:]), opacity=0.7, theta=[ ' 피안타율(AVG) ', ' 피출루율(OBP) ', ' 평균실점(RA9) ', ' 평균자책점(ERA) ', ' 수비무관투구(FIP) ' ], fill='toself', name=value[i]), 1, 1) fig.add_trace( go.Table(header=dict(values=df.columns, height=32, fill_color='#6E757C', line_color='#6E757C', align='center', font=dict(color='white')), cells=dict(values=[ df.NAME, df.AVG, df.OBP, df.RA9, df.ERA, df.FIP ], fill_color='white', line_color='#6E757C', font=dict(color='black'), align='center', height=32)), 2, 1) fig.update_layout(height=610, margin=dict(l=0, r=0, t=35, b=0), template=None, polar=dict(radialaxis=dict(visible=True, showticklabels=False, ticks=''), angularaxis=dict(showticklabels=True, ticks='', tickfont_size=13)), yaxis=dict(anchor="free", side="left", position=0.015), xaxis=dict(tickmode='linear', dtick=1), legend=dict(orientation="h", yanchor="bottom", y=1.05, xanchor="center", x=0.5)) return fig return app
className="mr-1", color="info", href="https://open.spotify.com/playlist/65XgqkWUTIdLZm9rXqTp3x"), ]), ] recsCenter = dbc.Col( [ html.Center(children=[ html.Span(' ', className='mr-1'), dbc.CardGroup( dbc.Card( dbc.CardBody( dbc.CardColumns([ dbc.Card(pod1, color="light"), dbc.Card(trisacard, color="light"), dbc.Card(pod2, color="light"), ])))) ]) ], md=10, ) singleColumn = dbc.Col([], md=1) doubleColumn = dbc.Col([], md=2) tripleColumn = dbc.Col([], md=3) footer = dbc.Col( [ html.Div([ dbc.Alert(html.Center([ html.Span(' ', className='mr-1'),
def generate_table(df, max_rows=100000): """ table = dash_table.DataTable( id='database-table', columns=[{"name": i, "id": i} for i in df.columns], data=df.to_dict('records'), sort_action="native", sort_mode='native', style_table={'overflowX': 'scroll', 'overflowY': 'scroll', 'padding': '2px 22px',}, style_cell={"whiteSpace": "normal", "height": "auto", 'textAlign': 'left'}, page_size=300 ) """ # add css table = html.Table( # Header [html.Tr([html.Th(col) for col in df.columns])] + # Body [ html.Tr([html.Td(df.iloc[i][col]) for col in df.columns]) for i in range(min(len(df), max_rows)) ]) allCards = [] for index, row in df.iterrows(): source = "Source: " + row["Data Source"] titleCoord = "Project Title/Coordinator: " + row[ "Project Title/ Coordinator"] keyWrd = "Area of Interest: " + row["Key Words"] typeRes = "Type of Research: " + row["Type of Research"] descVal = "Description: " + row["Description"] contact = "Relevant Links/Point of Contact: " + row[ "Relevant Links/POC"] currCard = dbc.Card([ dbc.CardHeader([ html.H5(source, className="card-title"), html.P( titleCoord, className="card-text", ), html.P( keyWrd, className="card-text", ), html.H2( dbc.Button( "Click here for more!", id=f"collapse-button{index}", )) ]), dbc.Collapse( dbc.CardBody([ html.P( typeRes, className="card-text", ), html.P( descVal, className="card-text", ), html.P( contact, className="card-text", ) ]), id=f"collapse{index}", ), ]) allCards.append(currCard) cardVal = dbc.CardColumns(allCards, id="cardcolumns") tabs = dbc.Tabs([ dbc.Tab(cardVal, label="Card View"), dbc.Tab(table, label="Table View"), ]) final = html.Div(tabs) return final
) card_content_3 = [ dbc.CardImg(src="/assets/images/placeholder286x180.png", top=True), dbc.CardBody( [ html.H5("Card with image", className="card-title"), html.P( "This card has an image on top, and a button below", className="card-text", ), dbc.Button("Click me!", color="primary"), ] ), ] cards = dbc.CardColumns( [ dbc.Card(card_content_1, color="primary", inverse=True), dbc.Card(card_content_2, body=True), dbc.Card(card_content_1, color="secondary", inverse=True), dbc.Card(card_content_3, color="info", inverse=True), dbc.Card(card_content_1, color="success", inverse=True), dbc.Card(card_content_1, color="warning", inverse=True), dbc.Card(card_content_1, color="danger", inverse=True), dbc.Card(card_content_3, color="light"), dbc.Card(card_content_1, color="dark", inverse=True), ] )
url_list = [ 'https://www.facebook.com/i80846dx2/', 'https://twitter.com/i80486dx23419', 'https://www.instagram.com/takuya3419/' ] my_img = dbc.CardColumns([ dbc.Card([ dbc.CardImg(src="/static/face.png", top=True), dbc.CardBody([ html.H5("Beetle", className="card-title"), dbc.Button("Contact", color="primary", id="collapse-button"), dbc.Collapse([ dbc.Row([ dbc.Col( html.A(html.Img(src=icon, height="30px"), href=link)) for icon, link in zip(icon_name, url_list) ]) ], id="collapse", style={ 'padding': '10pt 0 0 0', 'borderWidth': '0' }) ]) ]) ]) hobby_list = ['ドライブ', 'サイクリング', 'サカナクション', 'KIRINJI'] hobby = [ dbc.CardImg(src="/static/hobby.png", top=True), dbc.CardHeader("趣味", style={'font-weight': 'bold'}),
sold_times_graph = [ dbc.CardBody([ html.H6("Product selling times", style={'textAlign': 'center'}), dcc.Graph(id="item_sold_times_chart", config={'displayModeBar': 'hover'}, style={ 'height': 300, }) ]) ] '''putting the cards all together into a masonry kind of layout''' card_row_1 = dbc.CardColumns([ dbc.Card(dropdown_card, body=True), dbc.Card(revenue_card, body=True), dbc.Card(last_30_graph, color='dark', inverse=True), dbc.Card(sold_together, body=True), dbc.Card(sold_times_graph, body=True), dbc.Card(units_sold_card, body=True), dbc.Card(best_seller_card, body=True), dbc.Card(out_of_stock_card, body=True) ]) content = html.Div([ dbc.Row([card_row_1]), ], id="page-content", style=CONTENT_STYLE) '''final app layout render''' app.layout = html.Div([navbar, content, sidebar]) # @app.callback( # Output("page-content", "children"), [Input("url", "pathname")]
dbc.CardColumns([ dbc.Card([ dbc.CardHeader([ dbc.Row([ dbc.Col( html.Img(src='/assets/favicon.ico', width='60px', className='img-fluid')), dbc.Col(html.P("IoT Limited", className="h2 text-light pt-2"), width=9), ], no_gutters=True), ], className=' bg-danger'), dbc.CardBody([ html.H5("Project by - Saurav Ganguly", className='text-danger') ]), ], color="danger", outline=True, className='text-center'), dbc.Card([ dbc.CardHeader("Temperature", className='h4 text-light bg-danger'), dbc.CardBody([ daq.Thermometer(id='thermometer', min=95, max=105, showCurrentValue=True, units="C", color="#FF5E5E", className='pt-2') ]), ], color="danger", outline=True, className='text-center'), dbc.Card([ dbc.CardHeader("Battery", className='h4 text-light bg-danger'), dbc.CardBody([ daq.GraduatedBar(id='graduatedbar', showCurrentValue=True, step=2, max=100, color="#FF5E5E", className='pt-3 pb-3') ]), ], color="danger", outline=True, className='text-center'), dbc.Card([ dbc.CardHeader("Speed", className='h4 text-light bg-danger'), dbc.CardBody([ daq.Gauge(id='gauge', showCurrentValue=True, units="MPH", min=0, max=100, color="#FF5E5E", className='pt-4'), ]), ], color="danger", outline=True, className='text-center'), dbc.Card([ dbc.CardHeader("Counter", className='h4 text-light bg-danger'), dbc.CardBody([ daq.LEDDisplay(id='leddisplay', size=60, color="#FF5E5E", className='pt-3 pb-4') ]), ], color="danger", outline=True, className='text-center'), dbc.Card([ dbc.CardHeader("Fuel", className='h4 text-light bg-danger'), dbc.CardBody([ daq.Tank(id='tank', min=0, max=10, showCurrentValue=True, units='gallons', color="#FF5E5E", style={'margin-left': '100px'}, className='pt-4 pb-4') ]), ], color="danger", outline=True, className='text-center'), ])
html.H5("Borrowing Options", className="card-title"), html.P( "Where can you get money to buy a house, buy a car or start a business? SAM's tips for how to qualify for a loan, including how your credit score affects your interest rates and common dangers of borrowing.", className="card-text", ), dbc.CardLink( "Know Your Borrowing Options", href= 'https://www.smartaboutmoney.org/Topics/Spending-and-Borrowing/Know-Borrowing-Options' ), ]), ] cards = dbc.CardColumns([ dbc.Card(card_content_6, color="danger", inverse=True), dbc.Card(card_content_7, color="light"), dbc.Card(card_content_8, color="dark", inverse=True), ]) layout = html.Div([ # 1st row__________________ dbc.Row([ dbc.Col(html.H3("Lender Prediction Page", style={'color': 'rgb(255,255,255)'}), width={ 'size': 6, 'offset': 5 }), ]), # col1 # 2nd row___________________
card = dbc.Card( dbc.CardBody([ html.H5(sl["name"], className="card-title"), html.P(sl["desc"]), html.Div([ dbc.Button(0, color="primary", id=uid), dbc.Button("Plus", color="success", id=plus_id), dbc.Button("Minus", color="danger", id=minus_id), ]), ]), className="border-primary", ) choices.append(card) index_page = html.Div([ dbc.Row(dbc.CardColumns(choices, className="mb-4")), dbc.Row( [ dbc.Card( [ html.P( "Each slice is about 5 x 5 inches, we normally recommend two slices.", className="text-center", ), ], style={"width": "100%"}, color="primary", inverse=True, className="border-secondary", ) ],
dbc.CardImg( src="/assets/tools.png", top=True, bottom=False, title="tools", alt='Loading Error', style={ 'height': '100%', 'width': '100%', }, ) ] cards = dbc.CardColumns([ dbc.Card(card_content_1, inverse=False), #color="primary", inverse=True), dbc.Card(card_content_3), #color="secondary", inverse=True), dbc.Card(card_content_tools), dbc.Card(card_content_cdp, style={"width": "100%"}), ]) #======================= # ------------------------------------------------------------------------------ # App layout layout = html.Div([ navbar.navbar(), html.Br(), html.H3("Background Information", style={'fontWeight': 'bold'}), cards, html.Br(), html.H3("Project Team", style={'fontWeight': 'bold'}), dbc.Row(cards_team),
dbc.CardColumns( children=[ dbc.Card([ dbc.CardBody([ html.H5('Patient Y\'s salient features', id='salient_features_card_title', className='card-title'), dcc.Loading( id='loading_salient_features_list', children=[ dbc.ListGroup(id='salient_features_list', children=[], style=dict(height='20em', marginBottom='1em')) ], type='default', ) ]) ], style=dict(height='26em')), dbc.Card([ dbc.CardBody([ html.H5('Feature importance on ts=X', id='ts_feature_importance_card_title', className='card-title'), dcc.Loading( id='loading_ts_feature_importance_graph', children=[ dcc.Graph(id='ts_feature_importance_graph', config=dict(displayModeBar=False), style=dict(height='20em', marginBottom='1em')) ], type='default', ) ]) ], style=dict(height='26em')), dbc.Card([ dbc.CardBody([ html.H5('Patient outcome', id='patient_outcome_text', className='card-title', style=dict(color=colors['header_font_color'])) ]) ], id='patient_outcome_card', color='secondary', style=dict(height='5em')), dbc.Card( [ dbc.CardBody([ html.H5('Final output', className='card-title'), dcc.Graph( id='final_output_graph', config=dict(displayModeBar=False), style=dict(height='5em', # marginBottom='1em' ), animate=True), ]) ], style=dict(height='12em')), # [TODO] Create a part that allows editing the selected sample and see its effect; # this button should redirect to that part dbc.Button('Reset data', id='reset_data_bttn', className='mt-auto', size='lg', block=True, disabled=True, style=dict(marginBottom='0.5em')), dbc.Button('Edit sample', id='edit_sample_bttn', className='mt-auto', size='lg', block=True), ], style=dict(marginTop='1em', marginLeft='2em', marginRight='2em')),
create_submit_modal(pet_id), create_pet_info_modal(pet_id, name, img, animal, year, weight, address) ], inverse=False, # change color of text (black or white) outline= True, # True = remove the block colors from the background and header ) return card_question cards = dbc.CardColumns(children=[ make_card(dict_values[key]['id'], dict_values[key]['card'], dict_values[key]['name'], dict_values[key]['breed'], dict_values[key]['date'], dict_values[key]['animal'], dict_values[key]['year'], dict_values[key]['weight'], dict_values[key]['address']) for key in values ], id='cards', style={'padding': '20px 100px 0px 100px'}) age_select_layout = html.Div([ html.Div([ html.Label(['Возраст:'], style={'font-weight': 'bold'}), html.P(), dcc.RangeSlider( id='age_range_slider', marks={ 0: '0', 2: '2', 4: '4',
), ] body = dbc.Container( [ html.Div( [ dbc.CardColumns( [ dbc.Card(card_content_1, color="info", inverse=True, style={"width": "30rem", "height": "10rem"}), dbc.Card(card_content_2, color="success", inverse=True, style={"width": "30rem", "height": "10rem"}), dbc.Card(card_content_6, color="danger", inverse=True, style={"width": "30rem", "height": "12rem"}), dbc.Card(card_content_10, color="success", inverse=True, style={"width": "30rem", "height": "16rem"}), dbc.Card(card_content_7, color="danger", inverse=True, style={"width": "30rem", "height": "10rem"}), dbc.Card(card_content_5, color="info", inverse=True, style={"width": "30rem", "height": "10rem"}), dbc.Card(card_content_12, color="success", inverse=True, style={"width": "30rem", "height": "7rem"}), dbc.Card(card_content_8, color="danger", inverse=True, style={"width": "30rem", "height": "13rem"}), dbc.Card(card_content_3, color="success", inverse=True, style={"width": "30rem", "height": "14rem"}), dbc.Card(card_content_11, color="success", inverse=True, style={"width": "30rem", "height": "10rem"}), dbc.Card(card_content_9, color="danger", inverse=True, style={"width": "30rem", "height": "13rem"}), dbc.Card(card_content_4, color="info", inverse=True, style={"width": "30rem", "height": "14rem"}), dbc.Card(card_content_13, color="danger", inverse=True, style={"width": "30rem", "height": "10rem"}), ] ) ],className="offset-by-one column" ) ], )
def update_bezos_text(n): ytd_td = datetime.datetime.now() - datetime.datetime(2020, 1, 1) ytd_seconds = ytd_td.total_seconds() bezos_secondly = round(amzn_df.iloc[-1].bezos_year / ytd_seconds) bezos_tot = bezos_secondly * n unemp_secondly = round( sum(unemp_df.unemployment[-3:]) / (3 * 7 * 24 * 60 * 60), 1) bezos_txt = [ dbc.Alert([ f'Hi, you have been on this page for ', dbc.Badge(f'{n} seconds', color="primary", className="mr-1"), '. In that time:' ], color="info") ] card_content_worth = [ dbc.CardHeader(f"Bezos' net worth has increased by: "), dbc.CardBody([ html.H3( [dbc.Badge(f"US${int(bezos_secondly * n)}", color='success')], className="card-title"), html.P( [ f"That is ", dbc.Badge(str(round(bezos_tot / median_us_income, 1)), color='primary'), " typical U.S. incomes' worth of money." ], className="card-text", ), ]) ] card_content_unemp = [ dbc.CardHeader(f"Meanwhile, just in the U.S.:"), dbc.CardBody([ html.H5([ dbc.Badge(f"{int(unemp_secondly * n)}", color='danger'), " unemployment filings were made" ], className="card-title"), html.P( f"{round(sum(unemp_df.unemployment[-3:])/10**6, 1)} million people filed for unemployment in the U.S. in the last 3 weeks. ", className="card-text", ), ]) ] card_content_inc_stats = dbc.CardBody([ html.Blockquote( [ html.P( html.Small(f"The typical (median) per-person income is:"), className="text-muted"), html. P(f"US${median_world_income} world-wide, and US${median_us_income} in the United States." ), html.Footer( html.Small([ 'Stats: ', html. A("U.S.", href= "https://fred.stlouisfed.org/series/MEPAINUSA672N"), ', ', html. A("World", href= "https://news.gallup.com/poll/166211/worldwide-median-household-income-000.aspx" ) ]), ), ], className="blockquote", ) ]) card_content_unemp_stats = dbc.CardBody([ html.Blockquote( [ html.P(html.Small( f"Typically, 1 to 1.2 million people file for unemployment benefits every month in the United States." ), className="text-muted"), html. P(f"The current figure ({round(sum(unemp_df.unemployment[-3:])/10**6, 1)} million in 3 weeks) is about {round(sum(unemp_df.unemployment[-3:])/(0.9*10**6), 1)} times the normal and unprecedented." ), html.Footer( html.Small([ html.A("Source", href="https://fred.stlouisfed.org/series/ICSA") ]), ), ], className="blockquote", ) ]) card_content_bezos_donations = [ dbc.CardHeader(f"Bezos' total COVID-19 donations:"), dbc.CardBody([ html.H5([ "Is about ", dbc.Badge( f"{round(100 * 10**6 / (bezos_secondly * 60 * 60 * 24), 2)}", color='warning'), " days' earnings" ], className="card-title"), html.P( [ f"He has pledged about US$100m to food banks, while his net worth has increased about ", dbc.Badge( str(round(amzn_df.iloc[-1].bezos_year / 10**9, 1)), color='success'), " billion U.S. dollars this year. " ], className="card-text", ), ]) ] card_content_donations_info = dbc.CardBody([ html.Blockquote( [ html.P(html.Small( f"By contrast, Jack Dorsey, Twitter and Square CEO, has donated $1bn to COVID-19 relief." ), className="text-muted"), html. P(f"Dorsey's donation is estimated to be about 28% of his net worth, vs Bezos' 0.075% donation" ), html.Footer( html.Small([ html.A("Source", href="https://fred.stlouisfed.org/series/ICSA") ]), ), ], className="blockquote", ) ]) cards = dbc.CardColumns([ dbc.Card(card_content_worth, color="success", outline=True), dbc.Card(card_content_inc_stats, color="secondary", outline=True), dbc.Card(card_content_unemp, color="danger", outline=True), dbc.Card(card_content_unemp_stats, color="warning", outline=True), dbc.Card(card_content_bezos_donations, color="warning", outline=True), dbc.Card(card_content_donations_info, color="info", outline=True), ]) bezos_txt.append(cards) return bezos_txt
def orders_card(submit_button, product, kit_type, upgrade_type): t0 = time.time() df_orders = feather.read_dataframe('app/data/current/orders/orders_data.feather') orders_cards_current = [] orders_cards_previous = [] #date variables current_day = pd.Timestamp(datetime.now().date()) first_day_current_month = month_dates()[0] current_day_previous_month = current_day - relativedelta(months=1) first_day_previous_month = month_dates()[2] df_orders_filtered = df_orders #Product Filtering if product != 'all': df_orders_filtered = df_orders_filtered[df_orders_filtered['code'] == product] #Kit Filtering if kit_type != 'all': df_orders_filtered = df_orders_filtered[df_orders_filtered['kit_type'] == kit_type] #Upgrade Filtering if upgrade_type != 'all': df_orders_filtered = df_orders_filtered[df_orders_filtered['upgrade_type'] == upgrade_type] #Count of Orders MTD count_orders_mtd = df_orders_filtered[(df_orders_filtered['order_created_at'] >= first_day_current_month) & (df_orders_filtered['order_created_at'] < (current_day + relativedelta(days=1)))].order_id.nunique() card = dbc.Card( [ dbc.CardBody( [ dbc.CardHeader("Current MTD # Orders", style={'font-size':'1em'}), dbc.CardText("{}".format(count_orders_mtd), style={'font-size':'2em'}), ] ), ]) orders_cards_current.append(card) #Count of Upgrades MTD count_upgrades_mtd = df_orders_filtered[(df_orders_filtered['order_created_at'] >= first_day_current_month) & (df_orders_filtered['order_created_at'] < (current_day + relativedelta(days=1))) & (df_orders_filtered['upgrade_type'] == 'upgrade')].order_id.nunique() #change date card = dbc.Card( [ dbc.CardBody( [ dbc.CardHeader("Current MTD # Upgrades", style={'font-size':'1em'}), dbc.CardText("{}".format(count_upgrades_mtd), style={'font-size':'2em'}), ] ), ]) orders_cards_current.append(card) #Count of Kit 1 Orders MTD count_kit_1_orders_mtd = df_orders_filtered[(df_orders_filtered['order_created_at'] >= first_day_current_month) & (df_orders_filtered['order_created_at'] < (current_day + relativedelta(days=1)))].kit_1_id.nunique() card = dbc.Card( [ dbc.CardBody( [ dbc.CardHeader("Current MTD # Kit 1 Orders", style={'font-size':'1em'}), dbc.CardText("{}".format(count_kit_1_orders_mtd), style={'font-size':'2em'}), ] ), ]) orders_cards_current.append(card) #Count of Orders Previous MTD count_orders_mtd = df_orders_filtered[(df_orders_filtered['order_created_at'] >= first_day_previous_month) & (df_orders_filtered['order_created_at'] < current_day_previous_month + relativedelta(days=1))].order_id.nunique() #change date card = dbc.Card( [ dbc.CardBody( [ dbc.CardHeader("Previous MTD # Orders", style={'font-size':'1em'}), dbc.CardText("{}".format(count_orders_mtd), style={'font-size':'2em'}), ] ), ]) orders_cards_previous.append(card) #Count of Upgrades Previous MTD count_upgrades_mtd = df_orders_filtered[(df_orders_filtered['order_created_at'] >= first_day_previous_month) & (df_orders_filtered['order_created_at'] < current_day_previous_month + relativedelta(days=1)) & (df_orders_filtered['upgrade_type'] == 'upgrade')].order_id.nunique() #change date card = dbc.Card( [ dbc.CardBody( [ dbc.CardHeader("Previous MTD # Upgrades", style={'font-size':'1em'}), dbc.CardText("{}".format(count_upgrades_mtd), style={'font-size':'2em'}), ] ), ]) orders_cards_previous.append(card) #Count of Kit 1 Orders Previous MTD count_kit_1_orders_mtd = df_orders_filtered[(df_orders_filtered['order_created_at'] >= first_day_previous_month) & (df_orders_filtered['order_created_at'] < current_day_previous_month + relativedelta(days=1))].kit_1_id.nunique() #change date card = dbc.Card( [ dbc.CardBody( [ dbc.CardHeader("Previous MTD # Kit 1 Orders", style={'font-size':'1em'}), dbc.CardText("{}".format(count_kit_1_orders_mtd), style={'font-size':'2em'}), ] ), ]) orders_cards_previous.append(card) t1 = time.time() print('orders cards', t1-t0) return dbc.CardColumns(orders_cards_current, style={'text-align':'center'}), dbc.CardColumns(orders_cards_previous, style={'text-align':'center'})
dbc.Row([ dbc.Col([ html.Br(), dbc.CardColumns([ dbc.Card([ dbc.CardHeader(html.H4('Website URL')), dbc.CardBody(id='insight-1'), ], color = 'primary', outline=True), dbc.Card([ dbc.CardHeader(html.H4('Website Validity')), dbc.CardBody(id='insight-2') ], color = 'primary', outline=True), dbc.Card([ dbc.CardHeader('Features Beyond 1-SD away from mean'), dbc.CardBody(id='score'), ], color = 'primary', outline=True), dbc.Card([ dbc.CardHeader(html.H4('Addresses Listed')), dbc.CardBody(id='insight-4'), ], color = 'primary', outline=True), dbc.Card([ dbc.CardHeader(html.H4('Common Addresses')), dbc.CardBody(id='insight-5'), ], color = 'primary', outline=True) # dbc.CardHeader('Key Insights:', # style={'fontWeight': 'bold', 'color':'white','font-size': '22px', 'backgroundColor':'#0F5DB6', 'height': '50px'}), ]), ], md = 6, style={'border': '1px solid', 'border-radius': 3, 'margin-top': 22, 'margin-bottom': 15, 'margin-right': 0}), dbc.Col([ dbc.Row([
def __generate_infobar(self): card_content_score = [ dbc.CardBody( [ html.H5('{0:.3g}'.format(self.era_model.average_era_score_assets), className="card-title"), html.P( "Ø ERA Score", className="card-text", ), ] ), ] # Determine the color of the Card depending on the era score if self.era_model.average_era_score_assets >= 7.0: color_card_score = "danger" elif self.era_model.average_era_score_assets < 4.0: color_card_score = "success" else: color_card_score = "warning" card_content_vul = [ dbc.CardBody( [ html.H5(str(self.era_model.total_vulnerabilities), className="card-title"), html.P( "Vulnerabilities", className="card-text", ), ] ), ] # Determine the color of the Card depending on the amount of vulnerabilities if self.era_model.total_vulnerabilities >= 100: color_card_vul = "danger" elif self.era_model.total_vulnerabilities < 25: color_card_vul = "success" else: color_card_vul = "warning" card_content_assets = [ dbc.CardBody( [ html.H5(str(self.era_model.amount_nodes), className="card-title"), html.P( "Assets", className="card-text", ), ] ), ] card_content_path = [ dbc.CardBody( [ html.P( self.era_model.filename, className="card-text", style={"font-weight": "bold"} ), html.P( "Current Filepath", ), ] ), ] cards = html.Div( [ dbc.CardColumns( [ dbc.Card(card_content_score, color=color_card_score, inverse=True), dbc.Card(card_content_vul, color=color_card_vul, inverse=True), dbc.Card(card_content_assets, color="secondary"), ], ), dbc.Card(card_content_path, color="secondary"), ] ) return cards
cards = dbc.CardColumns( [ dbc.Card( [ dbc.CardHeader("These cards are arranged in columns"), dbc.CardBody( [ dbc.CardTitle("This is a title"), dbc.CardText("And some text\nmore text\nmore text"), ] ), ] ), dbc.Card( [ dbc.CardHeader("Another card"), dbc.CardBody( [ dbc.CardTitle("This is a title"), dbc.CardText("And some text"), ] ), ], color="dark", inverse=True, ), dbc.Card( [ dbc.CardHeader("Yet another card"), dbc.CardBody( [ dbc.CardTitle("This is a title"), dbc.CardText("And some text"), ] ), ], color="primary", inverse=True, ), dbc.Card( [ dbc.CardHeader("Another card"), dbc.CardBody( [ dbc.CardTitle("This is a title"), dbc.CardText("And some text"), ] ), ], color="primary", outline=True, ), ] )
className="border border-light m-3 bg-secondary"), ] card_content_3 = [ html.A(href="apps/step4", children=[dbc.CardImg(src=app.get_asset_url('step2.png'))]), dbc.CardBody([ html.H5("Comparasion", className="card-title"), ], className="border border-light m-3 bg-secondary"), ] layout = html.Div([ dbc.CardColumns([ dbc.Card(card_content_1, color="secondary", className="border border-light mt-5"), dbc.Card(card_content_2, color="secondary", className="border border-light mt-5"), dbc.Card(card_content_3, color="secondary", className="border border-light mt-5"), ], className="align-self-center pt-5 pr-3 pl-3") ], style={ "width": "100", "height": "100vh" })