示例#1
0
def _make_callback_multiple_outputs():
    app.layout = html.Div([
        dcc.Input(id='num', type='number', value=5),
        html.Table([
            html.Tr([html.Td(['x', html.Sup(2)]),
                     html.Td(id='square')]),
            html.Tr([html.Td(['x', html.Sup(3)]),
                     html.Td(id='cube')]),
            html.Tr([html.Td([2, html.Sup('x')]),
                     html.Td(id='twos')]),
            html.Tr([html.Td([3, html.Sup('x')]),
                     html.Td(id='threes')]),
            html.Tr([html.Td(['x', html.Sup('x')]),
                     html.Td(id='x^x')]),
        ]),
    ])

    @app.callback([
        Output('square', 'children'),
        Output('cube', 'children'),
        Output('twos', 'children'),
        Output('threes', 'children'),
        Output('x^x', 'children')
    ], [Input('num', 'value')])
    def callback_a(x):
        return x**2, x**3, 2**x, 3**x, x**x
def number2scientific(x):
    """Translates a number to a scientific notation in html + dash"""
    s = f'{x:.2e}'
    base, exponent = s.split('e')
    base = float(base)
    exponent= int(exponent)
    return ['{:.1f}∙10'.format(float(base)), html.Sup('{}'.format(exponent))]
    
 def _header_components(self):
 	index_dict = dict([(x[1], x[0]+1) for x in enumerate(set(reversed(sum(list(self.authors.values()), []))))])
 	authors = []
 	for a in self.authors:
     	authors += [a]
     	authors += [html.Sup(",".join([str(index_dict[x]) for x in self.authors[a]]))]
     	authors += [", "]
 	authors = authors[:-1]
 	insts = []
 	for s in index_dict:
     	insts += [html.Sup(index_dict[s])]
     	insts += [s]
     	insts += [", "]
 	insts = insts[:-1]
 	title = html.H1(self.poster_title, style={"text-align":"center","font-size":"89px","color":self.text_color, "font-family": "Arial", "font-weight":"bold"})
 	authors = html.H2(authors,style={"text-align":"center","font-size":"59px","color":self.text_color, "font-family": "Arial", "font-weight":"bold"})
 	institutions = html.H3(insts, style={"text-align":"center","font-size":"48px","color":self.text_color, "font-family": "Arial", "font-weight":"bold"})
 	return title, authors, institutions
示例#4
0
def MakeInfotip(text, hover_style={}):
    _infotip = html.Div(
        [
            html.Sup(u'\u2139', style={'background-color': '#c7ebe1'}),
            html.Span(text, className='tooltiptext', style=hover_style),
        ],
        className='tooltip',
    )
    return _infotip
示例#5
0
def get_info(feature=None):
    header = [html.H4("US Population Density")]
    if not feature:
        return header + ["Hoover over a state"]
    return header + [
        html.B(feature["properties"]["name"]),
        html.Br(), "{:.3f} people / mi".format(
            feature["properties"]["density"]),
        html.Sup("2")
    ]
示例#6
0
def defect_html_title_name(fullname):
    x = fullname.split("_")
    if len(x) == 2:
        in_name, out_name = x
    elif len(x) == 3:
        in_name, out_name, charge = x
    else:
        raise ValueError

    if in_name == "Va":
        in_name = html.I("V")
    else:
        in_name = html.Span(in_name)

    result = [in_name, html.Sub(out_name)]
    if len(x) == 3:
        result.append(html.Sup(charge))
    return result
示例#7
0
def tooltip(message,
            idname,
            trigger='?',
            placement='right',
            trigger_is_sup=True,
            **kwargs):
    """Defines a tooltip (popover) that will be shown in the rendered page.
    It will place a <sup>`trigger`</sup> in the page within a span tag.
    Returns the list with all html elements.
    """
    if trigger_is_sup:
        return [
            html.Span(children=html.Sup(trigger, className='popover-link'),
                      id=idname),
            dbc.Tooltip(message, target=idname, placement=placement, **kwargs)
        ]
    else:
        return [
            html.Span(children=trigger, className='popover-link', id=idname),
            dbc.Tooltip(message, target=idname, placement=placement, **kwargs)
        ]
示例#8
0
def app_page_layout(page_layout, app_title="Etalab Pseudo", light_logo=False):
    return html.Div(
        id='main_page',
        children=[
            dcc.Location(id='url', refresh=False),
            html.Div(
                id='app-page-header',
                children=[
                    html.A(
                        id='dashbio-logo',
                        children=[
                            html.Img(src="./assets/MarianneLogo-3-90x57.png")
                        ],
                        href="https://www.etalab.gouv.fr/"),
                    html.H2([app_title, html.Sup("β")]),
                    html.A(id='gh-link',
                           children=['Voir sur Github'],
                           href="https://github.com/psorianom/pseudo_app",
                           style={
                               'color':
                               'white' if light_logo else 'black',
                               'border':
                               'solid 1px white'
                               if light_logo else 'solid 1px black'
                           },
                           target="_blank"),
                    html.Img(src='data:image/png;base64,{}'.format(
                        base64.b64encode(
                            open(
                                './assets/GitHub-Mark-{}64px.png'.format(
                                    'Light-' if light_logo else ''),
                                'rb').read()).decode()))
                ],
            ),
            html.Div(id='app-page-content', children=page_layout)
        ],
    )
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    dcc.Input(id='num', type='number', value=5),
    html.Table([
        html.Tr([html.Td(['x', html.Sup(2)]),
                 html.Td(id='square')]),
        html.Tr([html.Td(['x', html.Sup(3)]),
                 html.Td(id='cube')]),
        html.Tr([html.Td([2, html.Sup('x')]),
                 html.Td(id='twos')]),
        html.Tr([html.Td([3, html.Sup('x')]),
                 html.Td(id='threes')]),
        html.Tr([html.Td(['x', html.Sup('x')]),
                 html.Td(id='x^x')]),
    ]),
])


@app.callback([
    Output('square', 'children'),
    Output('cube', 'children'),
    Output('twos', 'children'),
    Output('threes', 'children'),
示例#10
0
 html.H5(
     html.B('Instructions'),
     style={
         "margin-bottom": "15px",
         "color": "maroon"
     },
 ),
 # dcc.Markdown(
 #     '''
 #     '''
 # ),
 html.Div(
     [
         html.P([
             'This tool calculates a t-squared (time squared or t',
             html.Sup('2'),
             ') heat release rate (HRR) curve, which is commonly used to estimate transient fire growth for fire protection design purposes. The t-squared parabolic growth equation is given by:',
         ],
                style={
                    "margin": "10px",
                    "font-size": "20"
                }),
         # html.P(
         #     '[Q_dot = alpha*t^2]',
         #     style={"margin": "10px"}
         # ),
         html.Img(
             src=('/assets/t2_eq1_mod.PNG'),
             style={
                 'height': '40px',
                 'margin-left': '20px'
示例#11
0
    },
    {
        'label': risk_personal_desc,
        'value': 'personal'
    },
]

main_panel_s1 = '''Eredu honetan oinarrituta, gela honek hurrengo pertsona kopurua edukitzeak segurua* izan beharko 
luke: '''

main_panel_s1_b = html.Span([
    html.Span('''100.000tik '''),
])
main_panel_s2_b = html.Span([
    html.Span('''-ko infekzio prebalentzia'''),
    html.Sup('''1'''),
    html.Span(
        ''' duen populazio batean COVID-19-aren transmisioa* murrizteko, leku honek ___ pertsona baino gutxiago 
    eduki beharko lituzke: ''')
])

main_panel_s1_c = html.Span([
    html.Span('''100.000tik '''),
])
main_panel_s2_c = html.Span([
    html.Span('''-ko infekzio prebalentzia'''),
    html.Sup('''1'''),
    html.Span(
        ''' duen populazio batean, COVID-19z kutsatzeko nire arriskua murrizteko, leku honek ___ 
    pertsona baino gutxiago eduki beharko lituzke: ''')
])
示例#12
0
         ]),
         html.Div([html.Br(), html.Br()]),
     ],
     style={"padding-bottom": 100},
 ),
 html.Div(
     [
         html.H4(
             [
                 html.A(
                     "Alan Le Goallec",
                     href=
                     "https://www.linkedin.com/in/alan-le-goallec-1990/",
                     style={"color": "white"},
                 ),
                 html.Sup("1, 2"),
                 ", ",
                 html.A(
                     "Sasha Collin",
                     href=
                     "https://www.linkedin.com/in/sasha-collin-a2941115b/",
                     style={"color": "white"},
                 ),
                 html.Sup("1+"),
                 ", ",
                 html.A(
                     "Samuel Diai",
                     href="https://www.linkedin.com/in/samueldiai/",
                     style={"color": "white"},
                 ),
                 html.Sup("1+"),
示例#13
0
                 az Egyéb paraméterek fülön meg lehet adni az immunitás mértékét is a populációban, ami oltás vagy 
                 korábbi fertőzés következtében felmerülhet.'''],
             className='faq-answer'),
])

risk_tol_desc = html.Div('''A veszélyeztetett csoportok, mint az idősek vagy az alapbetegséggel rendelkezők alacsonyabb kockázati plafont igényelhetnek.
A magasabb megengedhető kockázat mellett több fertőzés várható adott kitettség és kihasználtság mellett (részletek a Gyakran Ismételt Kérdések alatt).''',
                         style={'font-size': '13px', 'margin-left': '20px'})

# Main Panel Text
curr_room_header = "Helyiség:"
main_panel_s1 = "A modell alapján biztonságosnak kell lennie, ha a helyiségben tartózkodik: "

main_panel_s1_b = html.Span([
    html.Span('''A COVID-19 továbbadásának* korlátozásához egy olyan populációban, amelynek fertőzöttsége'''),
    html.Sup('''1 ''')
])
main_panel_s2_b = ''' / 100 000 fő, ebben a térben lehet legfeljebb: '''

main_panel_s1_c = html.Span([
    html.Span(
        '''Annak érdekében, hogy korlátozzam a saját megfertőződésem esélyét egy olyan populációban, 
        amelynek fertőzési gyakorisága'''),
    html.Sup('''1 ''')
])
main_panel_s2_c = ''' 100 000, ebben a térben lehet legfeljebb: '''

main_airb_trans_only_disc = html.Div(["Ez az ajánlás a megengedett kockázat (10%) alatt tartja ",
                                      html.Span(html.A(href=links.link_nature,
                                                       children="a légúti fertőzés",
                                                       target='_blank'), ),
示例#14
0
        '''η επιλεγμένη λειτουργία κινδύνου (Για να περιορίσω τον προσωπικό μου κίνδυνο ...) εξετάζει την 
    πιθανότητα μόλυνσης ενός συγκεκριμένου ατόμου. Είναι επομένως πολύ λιγότερο περιοριστική 
    και δεν πρέπει να χρησιμοποιείται για τη θέσπιση γενικών οδηγιών ασφάλειας.'''
    )
])

risk_mode_panel_header = "Πεδίο ρίσκου"
occupancy_panel_header = "Υπολογισμός ασφαλούς πληρότητας αίθουσας"
main_panel_s1 = '''Για να περιορίσετε τη μετάδοση COVID-19 * όταν ένα μολυσμένο άτομο εισέλθει σε αυτόν τον χώρο, 
δεν πρέπει να υπάρχουν περισσότερα από:'''

main_panel_s1_b = html.Span([
    html.Span(
        '''Για τον περιορισμό της μετάδοσης COVID-19 * σε έναν πληθυσμό με συχνότητα λοίμωξης'''
    ),
    html.Sup('''1'''),
    html.Span(''' ''')
])
main_panel_s2_b = ''' ανά 100.000, αυτός ο χώρος δεν πρέπει να έχει περισσότερο από: '''

main_panel_s1_c = html.Span([
    html.Span(
        '''To limit my chance of being infected by COVID-19 in a population with an infection prevalence'''
    ),
    html.Sup('''1'''),
    html.Span(''' of ''')
])
main_panel_s2_c = ''' per 100,000, this space should have no more than: '''

units_hr = 'ώρες'
units_min = 'λεπτά'
示例#15
0
# }

risk_conditional_desc = "Falls eine infizierte Person eintritt…"
risk_prevalence_desc = "Angesichts der Ausbreitung der Infektion…"
risk_personal_desc = "Um mein persönliches Risiko zu begrenzen…"
risk_options = [
    {'label': risk_conditional_desc, 'value': 'conditional'},
    {'label': risk_prevalence_desc, 'value': 'prevalence'},
    {'label': risk_personal_desc, 'value': 'personal'},
]

main_panel_s1 = "Basierend auf diesem Modell, sollte die Situation im Raum sicher sein bei: "

main_panel_s1_b = html.Span([
    html.Span('''Um die COVID-19- Übertragung * in der Bevölkerung mit einer Prävalenz'''),
    html.Sup('''1'''),
    html.Span(''' von ''')
])
main_panel_s2_b = ''' pro 100.000 zu begrenzen, sollte dieser Raum nicht mehr haben als: '''

main_panel_s1_c = html.Span([
    html.Span('''Um mein Risiko, in einer Bevölkerung mit einer Infektionsprävalenz'''),
    html.Sup('''1'''),
    html.Span(''' von ''')
])
main_panel_s2_c = ''' pro 100.000 mit COVID-19 infiziert zu werden, sollte dieser Raum nicht mehr haben als: '''

units_hr = 'Stunden'
units_min = 'Minuten'
units_days = 'Tage'
units_months = 'Monate'
示例#16
0
    html.Div(['z', html.Sub('h'), ' = '], style=style1),
    dcc.Input(id='app4-zh',
              type='number',
              min=0,
              max=1,
              step=0.01,
              value=0.25,
              style=dict(width='10%')),
    html.Div(['q', html.Sub('T'), ' [GeV] = '], style=style1),
    dcc.Input(id='app4-qT',
              type='number',
              min=0,
              step=0.1,
              value=0,
              style=dict(width='10%')),
    html.Div(['W', html.Sup('2'), html.Sub('(max)'), ' = '], style=style1),
    dcc.Input(id='app4-W2max',
              type='number',
              min=1,
              step=1,
              value=12,
              style=dict(width='10%')),
    dcc.Graph(id='app4-graph'),
    html.Br(),
])


@app.callback(Output('app4-graph', 'figure'), [
    Input('app4-zh', 'value'),
    Input('app4-qT', 'value'),
    Input('app4-W2max', 'value')
def layout():
    """Dynamically serve a layout based on updated DB values (for dropdown menu)"""
    # Needs db connection! (Set up tunnel if testing app locally)
    _ids = get_doc_ids_from_db()   
    dropdown_dates = {num2str_month(_id): _id for _id in _ids}

    children_list = [
        html.Div([
            html.H2('Topic modelling'),
            dcc.Markdown(
                dangerously_allow_html=True,
                children=('''
                Our goal in this section is to analyze whether female and male sources are more likely
                to be associated with specific topics in the news. We utilize data scraped from six<sup>1</sup>
                Canadian news organizations' websites, following which we identify the gender of those
                quoted (sources). We then perform large-scale topic discovery on each month's data using
                Latent Dirichlet Allocation (LDA), as shown below.
            '''))],
        ),
        html.Div(html.Img(src="/static/topic-pipeline-flowchart-1.png", style={'width': '100%'})),
        html.P([
            html.Sup(1),
            '''Note that there were seven outlets between October 2018 and March 2021, after which HuffPost Canada stopped publishing.'''
        ], style={'font-size': '95%'},
        ),
        html.Br(),
        html.H5('Select month'),
        html.P('From the dropdown menu below, select a recent month to view its results.'),
        dcc.Dropdown(
            id='date-dropdown',
            options=[
                {'label': date_str, 'value': date_num}
                for date_str, date_num in dropdown_dates.items()
            ],
            value=_ids[-1],
            className='dropdown'
        ),
        html.Br(),
        html.Div(id='top15_datestring'),
        html.Div(
            DataTable(
                id='topic-table',
                columns=[
                    {'name': 'Topic labels', 'id': 'topic_names'},
                    {'name': 'Keywords', 'id': 'topic_words'},
                ],
                style_table={'overflowX': 'auto'},
                style_cell={
                    'backgroundColor': 'rgba(102, 204, 204, 0.05)',
                    'textAlign': 'left',
                    'font_family': 'Arial', 
                    'padding': '0px 10px',
                },
                style_data={'height': 'auto', 'lineHeight': '30px'},
                style_header={
                    'backgroundColor': 'rgb(255, 255, 255)',
                    'text-align': 'left',
                },
                style_as_list_view=True,
            )
        ),
        html.Br(),
        html.Div(
            dcc.Loading(
                id='topic-load-progress',
                children=[
                    dcc.Store(id='topic-data')
                ])
        ),
        # html.H4('Topics per outlet'),
        html.H5('''
            Which topics were covered more extensively by each outlet?
        '''),
        html.Div([dcc.Graph(id='outlet-heatmap')]),
        html.Div(html.Img(src="/static/topic-pipeline-flowchart-2.png", style={'width': '100%'})),
        dcc.Markdown('''
            Once we identify topics, we calculate an aggregated quantity that we call *gender prominence*,
            which is a measure that characterizes whether a given topic (on average) featured more
            prominently in articles that quote one gender more frequently than they do the other.
            
            To do this, we separate our news corpus for the given month into two smaller corpora - one 
            with articles that contain majority-female sources (at least one more female source than male),
            and the other with articles that contain majority-male sources. These corpora are termed the
            "female corpus" and "male corpus" respectively.
        '''),
        html.Br(),
        # html.H4('Topics and gender representation among sources'),
        html.H5('''
            Which topics showed the largest difference in gender representation?
        '''),
        html.Div(id='female-male-corpus-stats'),
        html.Div([
            dcc.Graph(id='outlet-gender-heatmap'),
            dcc.Markdown('''
                Topics that are red exhibit 'female prominence', i.e., they are topics
                for which the mean topic intensity is much greater in the female corpus than
                it is in the male corpus. The opposite is true for topics that exhibit 'male prominence'
                (shown in blue).
            '''),
            html.Br(),
            html.H5('''
                Which topics were covered more extensively in the female corpus?
            '''),
            html.Div(id='female-corpus-stats'),
            dcc.Graph(id='female-topic-bars'),
            html.Br(),
            html.H5('''
                Which topics were covered more extensively in the male corpus?
            '''),
            html.Div(id='male-corpus-stats'),
            dcc.Graph(id='male-topic-bars'),
            html.Br(),
        ]),
        html.Br(),
        dcc.Markdown('''
            [Click here](/static/GGT_topic_model_technical_report.pdf) to learn more about
            the Gender Gap Tracker's topic modelling methodology.
        '''),
    ]
    return children_list
示例#18
0
    html.Span('''Figyelmeztetés: ''', style={'font-weight': 'bold'}),
    html.Span(
        '''a kiválasztott kockázati mód (Az egyéni kockázatom korlátozása érdekében…) egy adott egyén megfertőződésében
gondolkodik. Ezért sokkal megengedőbb, és nem szabad a közösségi biztonsági irányelvek meghatározásához használni.'''
    )
])

risk_mode_panel_header = "Kockázati mód"
occupancy_panel_header = "Számoljuk a biztonságos kihasználtságot"
main_panel_s1 = "A COVID-19 továbbadásának* korlátozásához azután, hogy egy fertőzött személy ebbe a térbe lép, nem lehet itt több, mint: "

main_panel_s1_b = html.Span([
    html.Span(
        '''A COVID-19 továbbadásának* korlátozásához egy olyan populációban, amelynek fertőzöttsége'''
    ),
    html.Sup('''1 ''')
])
main_panel_s2_b = ''' / 100 000 fő, ebben a térben lehet legfeljebb: '''

main_panel_s1_c = html.Span([
    html.Span(
        '''Annak érdekében, hogy korlátozzam a saját megfertőződésem esélyét egy olyan populációban, 
        amelynek fertőzési gyakorisága'''),
    html.Sup('''1 ''')
])
main_panel_s2_c = ''' / 100 000 fő, ebben a térben lehet legfeljebb: '''

units_hr = 'órát'
units_min = 'percet'
units_days = 'napot'
units_months = 'hónapot'
# Stylesheet:
stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

# App:
app = dash.Dash(__name__, external_stylesheets=stylesheets)

# Layout:
app.layout = html.Div([
                html.Div([
                    'X = ',
                    dcc.Input(id='input', type='number', value=10)
                ],
                    style={'width': '49%', 'display': 'inline-block'}
                ),
                html.Div([
                    html.Td(['x', html.Sup('2'), ' = '], style={'display': 'inline-block'}),
                    html.Output(id='square')
                ]),
                html.Div([
                    html.Td(['x', html.Sup('3'), ' = '], style={'display': 'inline-block'}),
                    html.Output(id='cubic')
                ])
             ])


# Callback:
@app.callback([Output('square', 'children'),
               Output('cubic', 'children')],
              [Input('input', 'value')]
)
def update(x):
示例#20
0
]

graph_title = "Taux d'occupation vs. taux d'exposition"
graph_xtitle = "Temps d'exposition maximum \u03C4 (heures)"
graph_ytitle = "Occupation maximale N"
transient_text = "Transitoire/temporaire"
steady_state_text = "Continu"
co2_safe_trace_text = "Seuil respiratoire limite"
guideline_trace_text = "Recommandation"

graph_title_co2 = "Concentration de CO\u2082 (ppm) limite vs. temps d'exposition"
graph_ytitle_co2 = "Concentration de CO\u2082 (ppm)"

co2_title = "Voir le seuil de Concentration de CO\u2082 recommandé"
co2_param_desc = '''La recommandation (pour les paramètres choisis ci-dessus) est exprimée ici sous la forme d'un seuil de concentration de CO\u2082 à ne pas dépasser.''' 
co2_prev_input_1 = html.Span(["Incidence", html.Sup('1'), html.Span(" : ")])
co2_prev_input_2 = " pour 100 000"
co2_atm_input_1 = "CO\u2082 ambiant : "
co2_atm_input_2 = " ppm"
co2_calc_1 = "Pour une durée d'exposition de "
co2_calc_2 = " heures, la concentration  en CO\u2082 à l'état d'équilibre, dans cet espace, est de "
co2_calc_3 = " (selon notre recommandation)."
co2_base_string = '{:,.2f} ppm'

co2_safe_sent_1 = "Cette limite excède le seuil conseillé pour la respiration, qui est de "
co2_safe_sent_2 = "."

co2_safe_footer = html.Span(['''Le seuil conseillé pour la respiration est interpolé selon ''',
                             html.A(href=links.link_usda_co2,
                                    children='''les limites fixées par l'USDA''',
                                    target='_blank'),
示例#21
0
# }

risk_conditional_desc = "यदि एक संक्रमित व्यक्ति…"
risk_prevalence_desc = "संक्रमण की व्यापकता को देखते हुए…"
risk_personal_desc = "मेरे व्यक्तिगत जोखिम को सीमित करने के लिए ..."
risk_options = [
    {'label': risk_conditional_desc, 'value': 'conditional'},
    {'label': risk_prevalence_desc, 'value': 'prevalence'},
    {'label': risk_personal_desc, 'value': 'personal'},
]

main_panel_s1 = "इस मॉडल के आधार पर, यह कक्ष निम्न अवधि तथा लोगों की संख्या के लिए सुरक्षित होना चाहिए: "

main_panel_s1_b = html.Span([
    html.Span('''यह जनसंख्या जहाँ कि'''),
    html.Sup('''1'''),
    html.Span(''' ''')
])
main_panel_s2_b = ''' प्रति 100,000 का संक्रमण प्रचलित है, कोविड -19 के संचरण को सीमित करने के लिए, इस स्थान में: '''

main_panel_s1_c = html.Span([
    html.Span('''कोविड-19 से संक्रमित होने की मेरी संभावना को सीमित करने के लिए'''),
    html.Sup('''1'''),
    html.Span(''',''')
])
main_panel_s2_c = ''' प्रति 100,000 के संक्रमण प्रचलन के साथ, इस स्थान में: '''

units_hr = 'घंटों'
units_min = 'मिनट'
units_days = 'दिनों'
units_months = 'महीने'
示例#22
0
 business performance. For instance, if a business does not expect to be impacted by weather and \
 the data reveals otherwise, it may point to a problem that needs attention. \
 Businesses with negligible weather correlations may also be attractive to investors who may\
 not want seasonal variations in portfolio performance. Of course in any decision, many different \
 variables must be considered; sensitivity to weather conditions could be an important\
 piece of the puzzle.",
           style=dict(fontSize='16'))
     ],
     className="row padded"),
 html.Br([]),
 html.Br([]),
 # Row 7: Plot bar plot for R^2 across businesses
 html.Div(
     [
         html.H5(['Business R',
                  html.Sup([2]), ' Distribution'],
                 className="gs-header gs-table-header padded",
                 style={
                     'textAlign': 'center',
                     'fontWeight': 'bold'
                 }),
         dcc.Graph(
             id='R-squared',
             figure={
                 'data': R2_chart([yb50, ts50]),
                 'layout': {
                     "height": 1000,  # px
                     "xaxis": dict(side='top'),
                     "yaxis": dict(autorange="reversed"),
                     "margin": dict(t=20, b=20, l=270),
                 }
示例#23
0
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    dcc.Input(id='input-number', type='number', value=5),
    html.Table([
        html.Tr([html.Td(['x', html.Sup(2)]),
                 html.Td(id='square')]),
        html.Tr([html.Td(['x', html.Sup(3)]),
                 html.Td(id='cube')]),
        html.Tr(
            [html.Td(['2', html.Sup('x')]),
             html.Td(id='two-to-the-power-of')]),
        html.Tr([
            html.Td(['3', html.Sup('x')]),
            html.Td(id='three-to-the-power-of')
        ]),
        html.Tr([html.Td(['x', html.Sup('x')]),
                 html.Td(id='x-raised-to-x')]),
    ])
])


# item
# first argument is the component id
    {'label': risk_prevalence_desc, 'value': 'prevalence'},
    {'label': risk_personal_desc, 'value': 'personal'},
]
risk_personal_warning = html.Span([
    html.Span('''Cuidado: ''', style={'font-weight': 'bold'}),
    html.Span('''o modo de risco selecionado (Para limitar o meu risco pessoal…) considera a 
    probabilidade de infecção de um só indivíduo. Por isso, o modo é mais restritivo e não 
    deveria ser utilizado para estabelecer normas de segurança para a população.''')])

risk_mode_panel_header = "Modo de Risco"
occupancy_panel_header = "Calcular Ocupação Segura"
main_panel_s1 = '''Com base neste modelo, este ambiente seria seguro* com: '''

main_panel_s1_b = html.Span([
    html.Span('''Para limitar a transmissão de COVID-19* em uma população com uma prevalência de infecção'''),
    html.Sup('''1'''),
    html.Span(''' de ''')
])
main_panel_s2_b = ''' em 100.000, este espaço não deve ter mais do que: '''

main_panel_s1_c = html.Span([
    html.Span('''Para limitar minha chance de ser infectado por COVID-19 em uma população com uma prevalência 
    de infecção'''),
    html.Sup('''1'''),
    html.Span(''' de ''')
])
main_panel_s2_c = ''' em 100.000, este espaço não deve ter mais do que: '''

units_hr = 'horas'
units_min = 'minutos'
units_days = 'dias'
示例#25
0
préexistante, requièrent un seuil de tolérance plus bas. Une tolérance du risque plus élevée signifiera plus de 
transmissions attendues pendant la période d'occupation du lieu (Cf Questions fréquentes pour plus de détails).''',
    style={
        'font-size': '13px',
        'margin-left': '20px'
    })

# Main Panel Text
curr_room_header = "Espace concerné :"
main_panel_s1 = "En se basant sur ce modèle, cet espace devrait être sûr pour: "

main_panel_s1_b = html.Span([
    html.Span(
        '''Pour limiter la transmission de COVID-19* dans une population où l'incidence '''
    ),
    html.Sup('''1'''),
    html.Span(''' est de ''')
])
main_panel_s2_b = ''' pour 100 000, cet espace ne devrait pas accueillir plus de: '''

main_panel_s1_c = html.Span([
    html.Span(
        '''Pour limiter mes risques d'être infecté par COVID-19 dans une population où l'incidence '''
    ),
    html.Sup('''1'''),
    html.Span(''' de ''')
])
main_panel_s2_c = ''' pour 100 000, cet espace ne devrait pas avoir plus de : '''

main_panel_six_ft_1 = "En revanche, la consigne de distance d'un mètre (ou 2 mètres) limiterait l'occupation à "
main_panel_six_ft_2 = ", ce qui serait contraire à la présente recommandation* après "
示例#26
0
def plot(df, hue, y, should_group_by_author, should_group_by_year, is_normalized, filename):
    global colors
    if not y:
        y = 'msg'
    metric = f' {metrics_dict[y].lower()}' if not is_normalized else f"% de l{'a' if 'words' == y or 'media' == y else 'o'}s {metrics_dict[y].lower()}"
    rounding = '.2f' if is_normalized else '.2s'
    hovertemplate = f'%{{y:{rounding}}}{metric}<extra></extra>'

    if should_group_by_author:
        x = 'author'
        if should_group_by_year:
            hue = f'year_{hue}' if hue else 'year'
        plotting_df = get_df_for_plotting(df=df, x=x, y=y, hue=hue)
    else:
        x = hue if hue else 'year'
        if should_group_by_year:
            hue = 'year'
        else:
            hue = None
        plotting_df = get_df_for_plotting(df=df, x=x, y=y, hue=hue)

    data = [go.Bar(
        x=plotting_df.index,
        y=plotting_df[c].values,
        text=c,
        textposition='auto',
        hovertemplate=hovertemplate,
        name=c,
        marker_color=colors[index % len(colors)] if should_group_by_author else '#4481e3'
    )
        for index, c in enumerate(plotting_df.columns)]

    layout = dict(
        height=700 if not should_group_by_author else 700 + (33 * (len(set(plotting_df.columns)) // 10)),
        showlegend=x == 'author',
        hovermode='closest',
        title=dict(
            text=(' '.join(filename.split()[:3] + ['<br>'] + filename.split()[3:])
                  if len(filename.split()) > 3
                  else filename)[:-4],
            x=0.5,
            xanchor='center',
            font=dict(
                size=30,
                family='Rockwell, monospace',
                color='black',
            )
        ),
        xaxis=dict(
            type='category',
            rangeslider=dict(
                visible=False
            )
        ),
        yaxis=dict(
            color='#7f7f7f',
            gridcolor='#eaeaea'
        ),
        paper_bgcolor='white',
        plot_bgcolor='white',
        legend=dict(
            x=0.5,
            y=-0.15,
            orientation='h',
            xanchor='center',
            font=dict(
                size=15
            )
        ),
        hoverlabel=dict(
            bgcolor='white',
            font=dict(
                size=16,
                family='Rockwell'
            )
        ),
        barnorm='percent' if is_normalized else None
    )

    figure = go.Figure(data=data, layout=layout)

    return html.Div(
        className='mx-3',
        children=[
            dcc.Graph(
                id='whatsapp-info',
                figure=figure
            ),
            html.Div(
                children=[
                    'Podés filtrar por autor/a! ',
                    dbc.Tooltip(
                        children='Haciendo click en cada uno de los nombres podés agregarlos o quitarlos. Haciendo doble click en uno, podés quedarte únicamente con ese.',
                        target='author_filter_instructions',
                    ),
                    html.Sup(id='author_filter_instructions', children='(?)')] if should_group_by_author else '',
                className='text-center mx-auto',
                style={'fontSize': 25}
            ),
            html.Br(),
            html.Br(),
            html.Br(),
        ]
    )
示例#27
0
    {'label': risk_personal_desc, 'value': 'personal'},
]
risk_personal_warning = html.Span([
    html.Span('''Warning: ''', style={'font-weight': 'bold'}),
    html.Span('''the selected risk mode (To limit my personal risk...) considers probability of 
transmission to a particular individual. It is thus far less restrictive and should not be used for establishing 
community safety guidelines.''')])

risk_mode_panel_header = "Risk Mode"
occupancy_panel_header = "Calculate Safe Occupancy"
main_panel_s1 = '''To limit COVID-19 transmission* after an infected person enters this space, 
there should be no more than: '''

main_panel_s1_b = html.Span([
    html.Span('''To limit COVID-19 transmission* in a population with an infection prevalence'''),
    html.Sup('''1'''),
    html.Span(''' of ''')
])
main_panel_s2_b = ''' per 100,000, this space should have no more than: '''

main_panel_s1_c = html.Span([
    html.Span('''To limit my chance of being infected by COVID-19 in a population with an infection prevalence'''),
    html.Sup('''1'''),
    html.Span(''' of ''')
])
main_panel_s2_c = ''' per 100,000, this space should have no more than: '''

units_hr = 'hours'
units_min = 'minutes'
units_days = 'days'
units_months = 'months'
示例#28
0
     style={
         'height': '40px',
         'margin-left': '20px'
     },
 ),
 html.
 P('which is valid above the flame height. The McCaffrey plume temperature correlation can be used in the intermittent and continuous flaming regions with other constants. For the sake of simplicity, only the plume region form of the correlation is used here.',
   style={
       "margin": "0px",
       "font-size": "20",
       "margin-left": "20px"
   }),
 html.P([
     'Note: An ambient temperature (T',
     html.Sub('\u221E'), ') of 20',
     html.Sup('\u00B0'), 'C is used.'
 ],
        style={
            "margin": "0px",
            "font-size": "20",
            "margin-left": "20px"
        }),
 html.P([
     'More information on the above equations can be found in the textbook',
     html.
     I('Enclosure Fire Dynamics by Karlsson and Quintiere.')
 ],
        style={
            "margin": "0px",
            "font-size": "20",
            "margin-left": "20px"
示例#29
0
        min=df['year'].min(),
        max=df['year'].max(),
        value=df['year'].min(),
        marks={str(year): str(year) for year in df['year'].unique()}
    ),

    # Multiple outputs example - input number and table values
    html.H3('Multiple Outputs Example', style={'padding-top':'50px'}),
    html.Div([
        dcc.Input(
        id='num',
        type='number',
        value=5
        ),
        html.Table([
            html.Tr([html.Td(['x', html.Sup(2)]), html.Td(id='square')]),
            html.Tr([html.Td(['x', html.Sup(3)]), html.Td(id='cube')]),
            html.Tr([html.Td([2, html.Sup('x')]), html.Td(id='twos')]),
            html.Tr([html.Td([3, html.Sup('x')]), html.Td(id='threes')]),
            html.Tr([html.Td(['x', html.Sup('x')]), html.Td(id='x^x')]),
        ])
    ])
])

# Callback does not modify the data, creates copies of the dataframe
# Don't change variables outside their scope, avoid expensive downloads/queries in callbacks

# Multiple Inputs callback:
@app.callback(
    Output('graph-with-slider', 'figure'),
    [Input('year-slider', 'value'), Input('gdp-dropdown', 'value')])
示例#30
0
         'value': i
     } for i in ['R1', 'R2', 'R3', 'R1prime', 'xN/xb', 'zN/zh']],
     value='R1',
     style=dict(width='38%'),
 ),
 html.Div('Choose external kinematics: '),
 html.Div('M [GeV] = ', style=style1),
 dcc.Input(id='app8-M',
           type='number',
           min=0.1,
           step=0.01,
           value=0.938,
           style=dict(width='10%')),
 html.Div(
     ['W',
      html.Sup('2'),
      html.Sub('cut'), ' [Gev]',
      html.Sup('2'), ' = '],
     style=style1),
 dcc.Input(id='app8-W2_cut',
           type='number',
           min=4,
           step=0.1,
           value=4,
           style=dict(width='10%')),
 html.Div(['x', html.Sub('Bj (max)'), ' = '], style=style1),
 dcc.Input(id='app8-x_bjmax',
           type='number',
           min=1e-5,
           max=1,
           step=0.01,