def update_description(n_clicks, button_value, plant_name, x, y): if n_clicks > 0: entry = self.scraper.get(plant_name) return P(entry['summary']) else: return P( 'When new plants are added, wikipedia entries about them will appear here' )
def create_toast_achievement_of_unlocks(self, scenario_id: int): scenario = self.get_scenario(scenario_id) party_section = [ P("Party", style={"border-bottom": "1px solid black"}) ] party_section += [P(a) for a in scenario.party_achievements] global_section = [ P("Global", style={"border-bottom": "1px solid black"}) ] global_section += [P(a) for a in scenario.global_achievements] return party_section if len( party_section) > 1 else [] + global_section if len( global_section) > 1 else []
def _set_layout(assets): asset_names = sorted(assets.keys()) header_elements = [ Div( [ H1("Data Asset Visualiser", className="header-title"), P("Load assets from JSON Lines files", className="header-description"), ], className="header", ), Div( dcc.Dropdown( id="asset-filter", options=[{"label": a, "value": a} for a in asset_names], value="", clearable=True, className="dropdown", ), className="menu", ), ] body = Div(_generate_body(), id="charts-body", className="wrapper") all_elements = header_elements + [body] return Div(all_elements)
def requirements_to_html(self): requirements = self.text_and_cond_to_html(self.requirements, "Complete") anti_requirements = self.text_and_cond_to_html(self.anti_requirements, "Incomplete") alt_requirements = self.text_and_cond_to_html(self.alt_requirements, "Complete") return requirements + anti_requirements + ( [P("Or")] + alt_requirements if len(alt_requirements) > 0 else [])
def update_description(n_clicks, button_value, plant_name, x, y): if n_clicks > 0: entry = self.scraper.get(plant_name) latin = entry['latin_name'] common = entry['common_name'][0] habitat = entry['habitat'] height = entry['height'] soil = ' or '.join(entry['soil']) shade = ' or '.join(s if s != 'none' else 'no' for s in entry['shade']) moist = ' or '.join(entry['moisture']) description = f'''The {latin}, or {common} lives in a {habitat} habitat, grows to around {height}m, prefers {soil} and {moist} soil with {shade} shade''' return P(description) else: return P( 'When new plants are added, wikipedia entries about them will appear here' )
def index() -> Div: ''' Returns the app index page ''' return Container([ Row([ Col([ H1('Welcome to the Index Page'), P('You can visit a second page by' ' clicking the link below'), internal_link('Hello Page', href='/hello'), ]) ]) ])
def card(img_src, title, text, btn_text, btn_href): body = Div([ Div([ Img(src=img_src, className='card-img-top', width='100%') ]), Div([ H5(title, className='card-title'), P(text, className='card-text') ], className='card-body'), Div([ dcc.Link(btn_text, href=btn_href, className='btn btn-primary', style={'color': 'white'}) ], className='card-footer') ], className='card') return body
def load_app(app): """ Callback loading given app into the appropriate :class:`Div` class instance. Parameters ---------- app : unicode App path. Returns ------- Div :class:`Div` class instance of the app layout. """ if app == app_1.APP_PATH: return app_1.LAYOUT elif app == app_2.APP_PATH: return app_2.LAYOUT else: return Div([ P([ 'Various colour science ', A('Dash', href='https://dash.plot.ly/', target='_blank'), ' apps built on top of \n', A('Colour', href='https://github.com/colour-science/colour', target='_blank'), '.' ]), H3([ Link(app_1.APP_NAME, href=app_1.APP_PATH, className='app-link') ]), Markdown(app_1.APP_DESCRIPTION.replace('This app c', 'C')), H3([ Link(app_2.APP_NAME, href=app_2.APP_PATH, className='app-link') ]), Markdown(app_2.APP_DESCRIPTION.replace('This app c', 'C')), ])
def create_app(): app = Flask(__name__) dash_app = Dash(__name__, server=app, url_base_pathname='/dash/', external_stylesheets=[{ "href": "https://fonts.googleapis.com/css2?" "family=Lato:wght@400;700&display=swap", "rel": "stylesheet", }]) dash_app.layout = Div(children=[ Div(children=[ P(children='📈', className='header-emoji'), H1(children='Dash-PTS', className='header-title'), P( children=''' A Free and Open Source project-tracking systems tool: ''', className='header-description', ), P( children='https://github.com/dunossauro/dash-pts', className='header-description', ), ], className='header'), Div( children=[ Div(children=[ Div(children='Department', className='menu-title'), Dropdown(id='department-name', options=[{ 'label': i, 'value': i } for i in ['Sales', 'R&D', 'Support']], value='R&D', className='dropdown') ], ), Div(children=[ Div(children='Team', className='menu-title'), Dropdown( id='team-name', options=[{ 'label': i, 'value': i } for i in ['Data Science', 'Mobile', 'WEB', 'QA']], value='Mobile', className='dropdown') ], ), ], className='menu', ), Div( children=[ Graph( id='burn-down', className='card', config={'displayModeBar': False}, ), Graph( id='velocity', className='card', config={'displayModeBar': False}, ) ], className='wrapper', ) ], ) @app.route('/dash') def index(): return dash_app.index() @dash_app.callback([ Output(component_id='burn-down', component_property='figure'), Output(component_id='velocity', component_property='figure'), ], [ Input(component_id='team-name', component_property='value'), Input(component_id='department-name', component_property='value'), ]) def generate_graphs(team_name, department_name): return (burn_down( sprint='', initial_data=datetime(2021, 4, 5), final_data=datetime(2021, 4, 16), total_points=50, sprint_data=[50, 45, 41, 37, 39, 39, 39, 35, 27, 13], ), velocity({ 'names': ['Sprint ' + str(x) for x in range(1, 7)], 'commitment': [50, 47, 61, 53, 50, 51], 'completed': [52, 43, 58, 58, 49, 39], })) return app
def __init__(self, error): super().__init__( [P('There was an error with tracing:'), P(error)], color='danger', duration=6000, dismissable=True )
config = {'edits': {'shapePosition': True}} graphdcc = dcc.Graph(id='tested_graph', figure=wind_figure(dflb, times=[('2018-12-12', '2018-12-13')]), style={ "width": "98%", 'height': '98%' }, config=config) div0 = TileDiv([Span("Page de test des tracés", className='app-title')], className="header") div1 = TileDiv([graphdcc], nrows=8, className='chart_div') div2 = TileDiv( [H1("Relayout data"), P(id='relayout-data')], nrows=4, className='chart_div') div3 = TileDiv([P('some text')], className='chart_div') apptest.layout = Div(generate_layout(div0, div1, div2, div3)) @apptest.callback(Output('relayout-data', 'children'), [Input('tested_graph', 'relayoutData')]) def display_selected_data(relayoutData): return json.dumps(relayoutData, indent=2) # @apptest.callback( # Output('tested_graph','figure'),
from dash import Dash from dash_html_components import Div, P, Br from dash_core_components import Input as DCCInput from dash.dependencies import Input, Output app = Dash(__name__) app.layout = Div(children=[ DCCInput(id='meu_input1', value='batatinha frita'), Br(), DCCInput(id='meu_input2', value='Quantas saias a barata tem?'), P(id='output1'), P(id='output2') ]) @app.callback([Output('output1', 'children'), Output('output2', 'children')], [ Input('meu_input1', 'value'), Input('meu_input2', 'value'), ]) def meu_callback(meu_input1, meu_input2): return meu_input1, meu_input2 app.run_server()
from dash_html_components import Div, Img, Button, H2, H1, P, Hr, A, Span, Label from templates.wordcloud import wordloud_controls import dash_core_components as dcc from dash.dependencies import Input, Output, State from app import app from templates.wordcloud import make_word_cloud, footer body = Div([ Div([ Div([ H1("Text Upload Word Cloud Generator", className='display-4'), Hr(), P('This is the text upload word cloud generator. Simply upload a UTF-8 encoded .txt file.' ), ], className='container') ], className="jumbotron jumbotron-fluid"), Div([ Div([ Div('Text Upload Wordcloud', className='card-header'), dcc.Loading(Div([ H2('', className='card-title'), Div([Img(src='', className='card-img-top', width='100%')], style={'height': 500}), ], className='card-body', id='text-upload-wordcloud'), style={ 'paddingTop': 200, 'paddingBottom': 200
# 'title': 'MM Heat Maps' # }), # '/maps/choro': dot({ # 'layout': choro_maps_page, # 'nav': 'Choropleth', # 'title': 'MM Choropleth Maps' # }) }) # # App Base Layout # app.layout = Div([ Location(id='url', refresh=True), Navbar(routes), Main(P('Loading...', style={'text-align': 'center'}), id='app-main') ], id='app-root') @app.callback(DOutput('app-main', 'children'), [DInput('url', 'pathname')]) def display_main(pathname): return routes[pathname].layout # # Args # argparser = argparse.ArgumentParser()
prices_df = pd.read_csv(__prices_file) names = prices_df["name"].unique() names = names[1:20] shops = prices_df.shop.unique() selected = dot({'shop': None, 'kind': None}) #TODO: #Dropdown limit #Shop dropdown? #Line evolution_page = [ Container([ H1('Evolution'), H4('Select product'), P("Shop"), dcc.Dropdown(id='shopEvo', options=[{ 'label': i, 'value': i } for i in shops], value=[i for i in shops], placeholder="Shop"), P("Kind"), dcc.Dropdown(id='productEvo', ), Button("Load Products", id="LoadNamesEvo", n_clicks=0), P("Product name"), dcc.Dropdown(id='evolutionDropdown', ), dcc.Graph(id="evolutionGraph") ], id='app-main-evolution')
from dash_html_components import Div, Img, Button, H2, H1, P, Hr, A, Span, Label from templates.wordcloud import wordloud_controls import dash_core_components as dcc from dash.dependencies import Input, Output, State from app import app from templates.wordcloud import make_word_cloud, footer from templates.amazonIframe import amazonMusicProduct import lorem body = Div([ Div([ Div([ H1("Copy & Paste Word Cloud Generator", className='display-4'), Hr(), P('This is the copy & paste word cloud generator. Simply copy and paste the text into the box below.' ), ], className='container') ], className="jumbotron jumbotron-fluid"), Div([ Div([ Div('Text Field Wordcloud', className='card-header'), dcc.Loading(Div([ H2('', className='card-title'), Div([Img(src='', className='card-img-top', width='100%')], style={'height': 500}), ], className='card-body', id='text-field-wordcloud'), style={
# title and subtitle Div([ # title H1(children='catalog-dash'), # subtitle H3(children='Download table analysis') ], style={'textAlign': 'center', 'color': colors['text']}), # top tables - information table, date picker range and limit Div([ # left table - information table Div([ # title P( children='Table: Information', style={'color': colors['text']} ), # table information DataTable( id='download--table--information', columns=[{'name': i, 'id': i} for i in df_information.columns], data=df_information.to_dict('records'), fixed_rows={'headers': True, 'data': 0}, **get_table_styles() ), ], style={'maxWidth': '500px', 'marginRight': '10px'}), # right table - date picker range and limit form Div([ # date picker range Div([
Div([ dcc.Link(btn_text, href=btn_href, className='btn btn-primary', style={'color': 'white'}) ], className='card-footer') ], className='card') return body body = Div([ Div([ Div([ Div([ H1("Word Cloud World", className='display-4 text-center'), Img(src="/static/world.png", width="300", height="300", alt="", style={'display': 'block', 'margin': '0 auto'}) ], className=''), P("Welcome!", className="lead text-center"), Hr() ], className='container') ], className="jumbotron jumbotron-fluid", style={'background-image': '/static/world.png'}), Div([ P("""Welcome to Word Cloud World! Word clouds are a creative way to visually represent textual data. They allow you to see the most significant or frequent words used in any body of text. Here at Word Cloud World we have created automated apps to visualise Wikipedia articles or Song lyrics. You can also create your own word cloud by cutting and pasting text or by uploading a textfile! You can customize your word cloud by changing its colour, shape and size. """), H5('Some Inspiration'), Div([ card('/static/wiki-word-cloud.png', 'Wikipedia', 'Create word clouds from Wikipedia articles', 'Explore!', '/wordcloud/wikipedia'), card('/static/lyrics.png',
from dash_html_components import Div, Img, Button, H2, H1, P, Hr, A, Span, Label from templates.wordcloud import wordloud_controls import dash_core_components as dcc from dash.dependencies import Input, Output, State from templates.wordcloud import make_word_cloud, footer from templates.amazonIframe import amazonPrimeVideoProduct from app import app import wikipedia body = Div([ Div([ Div([ H1("Wikipedia Word Cloud Generator", className='display-4'), Hr(), P('This is the Wikipedia word cloud generator. Simply Enter the Article Name (exactly as seen on the wiki page) and click generate. Alternatively\ grab a random wikipedia article with the click of a button.') ], className='lead container') ], className="jumbotron jumbotron-fluid"), Div( [ # amazonPrimeVideoProduct, Div([ Div('Wikipedia Wordcloud', className='card-header'), dcc.Loading(Div([ H2('', className='card-title'), Div([Img(src='', className='card-img-top', width='100%')], style={'height': 500}), ], className='card-body',
def scenario_input_card(scen_name): """ Function to create the scenario input boxes """ return Div( children=[ Div( P([ "Number of big companies: ", Span( "\u003f\u20dd", id=scen_name + "-tooltip-num-big-firms", className="question-mark", ), ]), style={"margin-left": 2}, ), dbc.Tooltip( HOVERTEXTS["Number of big companies"], target=scen_name + "-tooltip-num-big-firms", style=TOOLTIP_STYLE, placement="right", arrowClassName="arrow", ), RadioItems( id=scen_name + "-num-big-firms", options=[{ "label": x, "value": x } for x in [1, 2, 3, 4, "None"]], labelStyle={ "display": "inline-block", "margin-right": "15px" }, inputStyle={ "margin-right": "6px", "verticalAlign": "middle" }, value=1, style={"margin-bottom": "4%"}, ), Div( P([ "Privacy concerns from customers: ", Span( "\u003f\u20dd", id=scen_name + "-tooltip-privacy-concern", className="question-mark", ), ]), style={"margin-left": 2}, ), dbc.Tooltip( HOVERTEXTS["Privacy concern"], target=scen_name + "-tooltip-privacy-concern", style=TOOLTIP_STYLE, placement="right", ), RadioItems( id=scen_name + "-privacy-concern", options=[{ "label": x, "value": x.lower() } for x in ["Low", "Medium", "High"]], labelStyle={ "display": "inline-block", "margin-right": "15px" }, inputStyle={ "margin-right": "10px", "verticalAlign": "middle" }, value="medium", style={"margin-bottom": "4%"}, ), Div( P([ "Consumer preference for multiple products from the same company: ", Span( "\u003f\u20dd", id=scen_name + "-tooltip-loyalty", className="question-mark", ), ]), style={"margin-left": 2}, ), dbc.Tooltip( HOVERTEXTS[ "Consumer preference for multiple products from the same company"], target=scen_name + "-tooltip-loyalty", style=TOOLTIP_STYLE, placement="right", ), RadioItems( id=scen_name + "-loyalty", options=[{ "label": x, "value": x.lower() } for x in ["Low", "Medium", "High"]], labelStyle={ "display": "inline-block", "margin-right": "15px" }, inputStyle={ "margin-right": "10px", "verticalAlign": "middle" }, value="medium", style={"margin-bottom": "4%"}, ), Div( P([ "Openness: ", Span( "\u003f\u20dd", id=scen_name + "-tooltip-openness", className="question-mark", ), ]), style={"margin-left": 2}, ), dbc.Tooltip( HOVERTEXTS["Openness"], target=scen_name + "-tooltip-openness", style=TOOLTIP_STYLE, placement="right", ), RadioItems( id=scen_name + "-openness", options=[{ "label": x, "value": x.lower() } for x in ["Low", "Medium", "High"]], labelStyle={ "display": "inline-block", "margin-right": "15px" }, inputStyle={ "margin-right": "10px", "verticalAlign": "middle" }, value="medium", style={"margin-bottom": "4%"}, ), P( [ "Privacy shock ", Span( "\u003f\u20dd", id=scen_name + "-tooltip-privacy", className="question-mark", ), ], style={ "margin-bottom": "0%", "margin-left": 2 }, ), P( "(can be applied to several firms)", style={ "font-size": "12px", "margin-bottom": "0%" }, ), dbc.Tooltip( HOVERTEXTS["Privacy shock"], target=scen_name + "-tooltip-privacy", style=TOOLTIP_STYLE, placement="right", ), Checklist( id=scen_name + "-privacy-onoff", options=[{ "label": "Include a privacy shock", "value": True }], values=[], inputStyle={"margin-right": "5px"}, style={ "margin-bottom": "2%", "margin-top": "0%" }, ), RadioItems( id=scen_name + "-shock-num", options=[{ "label": x, "value": x } for x in [1, 2, 3, 4]], labelStyle={ "display": "inline-block", "margin-right": "15px", "padding-bottom": ITEM_BOTTOM, }, inputStyle={"margin-right": "10px"}, value=1, style={"margin-bottom": "4%"}, ), ], className="scenario-input", style={ "background-color": "rgb(234, 234, 234)", "font-size": "16px" }, )
className="custom-tab", selected_className="custom-tab--selected", ) for x, y in TAB_DICT.items() ], value=list(TAB_DICT.keys())[0], colors={ "background": "white", "border": "#d6d6d6", "primary": "#1975FA", }, ), Div( children=[ P( id="tab-text", style={"margin": "20px", "font-size": "13px"}, ) ] + [ Div( Graph( id=x + "-graph" ), id=x + "-graph-div", style={"display": "none"} ) for x in TAB_DICT.keys() ], style={"border": "1px solid #d6d6d6"}, ), ],
def makeRoot_Contents(): return Container( [ Div(id='store', hidden=True), Modal([ ModalHeader([ B('Welcome to the Global Risk Management Visualization') ]), ModalBody( P([ B('Global risk data for everyone'), P('It is frustrating when you can nott make a qualified assessment on the global risk position of a multinational corporation due to the enormous complexity of its operations. The global risk visualization addresses that challenge by offering the most intuitive options to interact with corporate risk data all in one place.' ), B('Valuable insights through disparate data connections' ), P('By connecting financial performance, global footprint, and national risk data for over 100 countries, the visualization helps you get a better sense of the political, economic and financial risks facing these organizations.' ), Hr(), B('Target Audience:'), P('Investors, Students, Corporate Legal and Researchers' ), Hr(), B('Data Sources:'), P('Yahoo Finance, PRS Global Risk Dataset, Orbis Global Footprint Dataset, and SAP Capital IQ M&A Dataset' ), Hr(), B('Team:'), P('Jay Venkata, Keith Wertsching, and Pri Nonis'), Hr(), Iframe( src= 'https://zoom.us/rec/play/vJYqcu-grzM3SIWW5ASDB_IqW9W9La6sgyke8qdYyx63VSZRYVCuMuYRMAI0fIKQL0LNUUuXXcgTFVo', width=1106, height=650) ])), ModalFooter(Button('Close', id='close', className='ml-auto')), ], id='modal', size='xl', is_open=True), makeRoot_ToolsBar(), Row( [ Col( makeCard('stock-plot', 'manda', hide=False), width=12, ), # Col( # makeCard('table-plot', 'manda', hide = False), # width = 3 # ), ], className='manda'), Row([ Col(makeCard('world-plot', 'risks', hide=True), width=6, style={'paddingRight': '0rem'}), Col(makeCard('total-plot', 'risks', hide=True), width=6), ], className='risks t1p'), Row([ Col(makeCard('burst-plot', 'risks', hide=True), width=3, style={'paddingRight': '0rem'}), Col(makeCard('trend-plot', 'risks', hide=True), width=9), ], className='risks v1p'), ], fluid=True, style={})
def create_html_party_achievements(self): return [P(a) for a in self.party_achievements]
'position' : 'relative', 'padding-top' : 0, 'padding-right' : 0 })], href="https://www.linkedin.com/in/karthikanumalasetty/", target="_blank", )]), Div([A([Img( src='data:image/jpg;base64,{}'.format(github_image.decode()), style={ 'height' : '8%', 'width' : '8%', 'float' : 'right', 'padding-top' : 0, 'padding-right' : 0 })], href="https://github.com/KKAnumalasetty/simulation-app-heroku", target="_blank", )]), P('Unit Margin = $50 and Lead Time for Purchase Order = 2 days'), Div([P('Days to simulate (1 to 30 days) :')],style={'display': 'inline-block'}), Div([P(id='days-slider-output')],style={'display': 'inline-block','color':'red','padding':'20px','font-size':'160%'}), Div([Slider( id='days-slider', min=0, max=30, step=1, value=25, updatemode='drag', )],style={"width" : "25%"}), Div([P('Inventory Cutoff level (units 1 to 100) :')],style={'display': 'inline-block'}), Div([P(id='inv-cutoff-slider-output')],style={'display': 'inline-block','color':'red','padding':'20px','font-size':'160%'}), Div([Slider( id='inv-cutoff-slider', min=0,
def text_to_html(text: str): return [P(paragraph) for paragraph in text.split('\n')]
def text_and_cond_to_html(requirements: str, cond: str): return [P(f'{requirement} ({cond})') for requirement in requirements]
# title and subtitle Div([ # title H1(children='catalog-dash'), # subtitle H3(children='Scene table analysis'), ], style={'textAlign': 'center', 'color': colors['text']}), # number of scenes and information tables Div([ # left div - number of scenes table Div([ # title P( children='Table: Number of Scenes by Dataset and Year-Month', style={'color': colors['text']} ), # number of scenes table DataTable( id='scene--table--number-of-scenes', columns=[{'name': i, 'id': i} for i in df_sd_dataset_year_month.columns], data=df_sd_dataset_year_month.to_dict('records'), fixed_rows={ 'headers': True, 'data': 0 }, **get_table_styles(), sort_action='native', sort_mode='multi', filter_action='native', page_size=50, ), ], style={'width': '50%', 'marginRight': '10px'}),
def map_str_to_html(self, tile_id: str): # Img(src=f'./assets/scenario_tiles/{tile_id}.png', style={"max-width": "50%"}) return P(tile_id)
from dash_html_components import Div, Img, Button, H2, H1, P, Hr, A, Span, Label from templates.wordcloud import wordloud_controls import dash_core_components as dcc from dash.dependencies import Input, Output, State from app import app from PyLyrics import PyLyrics from templates.wordcloud import remove_html_tags, make_word_cloud, footer from templates.amazonIframe import amazonMusicProduct body = Div([ Div([ Div([ H1("Lyrics Word Cloud Generator", className='display-4'), Hr(), P('This is the Lyrics word cloud generator. Simply Enter the Artist Name and Song and click generate.' ), ], className='container') ], className="jumbotron jumbotron-fluid"), Div( [ # amazonMusicProduct, Div([ Div('Lyrics Wordcloud', className='card-header'), dcc.Loading(Div([ H2('', className='card-title'), Div([Img(src='', className='card-img-top', width='100%')], style={'height': 500}) ], className='card-body',