Esempio n. 1
0
    def contents_layout(self):

        state = {"symprec": 0.01, "angle_tolerance": 5}

        symprec = self.get_numerical_input(
            label="Symmetry-finding tolerance",
            kwarg_label="symprec",
            state=state,
            help_str="Tolerance of distance between atomic positions and between lengths "
            "of lattice vectors to be tolerated in the symmetry finding in Ångstroms. "
            "The angle distortion between lattice vectors is converted to a length and "
            "compared with this distance tolerance.",
            shape=(),
            min=0,
        )
        angle_tolerance = self.get_numerical_input(
            label="Angle tolerance",
            kwarg_label="angle_tolerance",
            state=state,
            help_str="Explicit angle tolerance for symmetry finding in degrees. "
            "Set to a negative value to disable.",
            shape=(),
        )

        return html.Div(
            [
                symprec,
                angle_tolerance,
                html.Br(),
                html.Br(),
                Loading(id=self.id("analysis")),
            ]
        )
Esempio n. 2
0
def render_output_panel(area_select):
    data.process_data_for_area(area_select)
    card = html.Div([
        dbc.Card(className="bg-dark text-light",
                 children=[
                     dbc.CardBody([
                         html.H4(area_select,
                                 id="card-name",
                                 className="card-title"),
                         html.Br(),
                         html.H6("Compared to England:",
                                 className="card-title"),
                         html.H4("{:,.0f}%".format(data.compare_to_eng),
                                 className="card-text text-light"),
                         html.Br(),
                         html.H6(
                             "Compared to previous year:".format(area=area),
                             className="card-title"),
                         html.H4("{:,.0f}%".format(data.change_area),
                                 className="card-text text-light"),
                         html.Br(),
                         html.H6("Best period:", className="card-title"),
                         html.H4(data.best_period,
                                 className="card-text text-light"),
                         html.H6("with recycling rate {:,.0f}%".format(
                             data.best_rate),
                                 className="card-title text-light"),
                         html.Br()
                     ])
                 ])
    ])
    return card
Esempio n. 3
0
 def get_regional_emissions_comparison():
     return html.Div(
         dbc.Col(
             [
                 html.Br(),
                 html.Br(),
                 html.H2(
                     [
                         "Emissions Across Regions in ",
                         html.Strong(
                             id="country_name",
                             style={
                                 "fontWeight": "normal",
                                 "color": "green"
                             },
                         ),
                     ],
                     style={
                         "textAlign": "center",
                         "marginLeft": "12%"
                     },
                 ),
                 dcc.Graph(id="regional_emissions_comparison_choropleth"),
             ],
             id="regional_emissions_comparison_component",
         ),
         style={"marginLeft": "-12%"},
     )
Esempio n. 4
0
    def welcomePage(self):
        title = html.H1(
            "Recount",
            style={
                "marginBottom": "-1rem",
                "fontSize": "8rem",
                "fontWeight": "bold",
            },
        )
        subtext_title = html.Strong("Gonna check dat budget!",
                                    style={"fontSize": "3rem"})
        upper_welcome = html.Div([title, subtext_title],
                                 style={"textAlign": "center"})

        welcome = html.H2([html.Br(), "Welcome"],
                          style={
                              "fontSize": "6rem",
                              "fontWeight": "bold"
                          })
        paraf1 = html.P([
            "Bonjour et bienvenu sur ",
            html.Strong("Recount"),
            ", une application qui permet de visualiser ses dépenses.",
        ])
        paraf2 = html.P([
            html.Br(),
            "La ",
            "version 0.1",
            " viens de sortir, et ",
            html.Strong("vous avez été choisi pour la tester!"),
        ])
        paraf3 = html.P([
            "Testez, jouez avec les données, et faites moi des retours par mail quand vous le souhaitez à ",
            html.A("*****@*****.**"),
        ])
        paraf4 = html.P([
            "Si vous voulez un petit ",
            html.Strong("tuto"),
            " pour vous lancer, j'ai préparé ",
            html.A("celui-ci."),
        ])
        paraf5 = html.P([
            html.Br(),
            "Niveau sécurité, tout les fichiers sont chiffrés et les connexions sécurisées. Mais je ne vais pas mentir : tout est cadenassé, mais les clefs ne sont pas cachées. Il faut partir du principe qu'",
            html.Strong("une fuite de données peut arriver TRÈS facilement."),
            " Si cela vous dérange d'entrer vos dépenses personnelles, utilisez les données de l'exemple ou inventez vos propres données.",
        ])
        paraf6 = html.P([
            html.Br(),
            "Je reste joignable sur mon téléphone, mail ou via facebook."
        ])
        paraf7 = html.P([html.Br(), "Amusez vous bien!"])

        list_parafs = [paraf1, paraf2, paraf3, paraf4, paraf5, paraf6, paraf7]
        for i in range(len(list_parafs)):
            list_parafs[i].style = {"fontSize": "xx-large"}
        parafs = html.Div(list_parafs)

        return html.Div([upper_welcome, welcome, parafs])
Esempio n. 5
0
 def get_project_time_series():
     return html.Div(
         dbc.Col([
             html.Br(),
             html.Br(),
             html.H2("Emissions Timeline", style={"textAlign": "center"}),
             dcc.Graph(id="project_time_series"),
         ]),
         style={"paddingLeft": "3%"},
     )
Esempio n. 6
0
 def get_project_emissions_bar_chart():
     return html.Div(
         dbc.Col([
             html.Br(),
             html.Br(),
             html.H2("Emissions Detail", style={"textAlign": "center"}),
             dcc.Graph(id="project_emissions_bar_chart"),
         ]),
         style={"paddingLeft": "3%"},
     )
Esempio n. 7
0
 def format_additional_content(self):
     container = html.Div(children=[])
     for content in self._record["additional_content"]:
         div = html.Div(children=[html.H3(content["title"]), html.Br()])
         for image in content["images"]:
             div.children.append(self.format_image(image))
         div.children.append(html.P(content["body"]))
         div.children.append(html.Br())
         container.children.append(div)
     return container
Esempio n. 8
0
 def format_associations(self):
     assocs = self._record["associations"]
     div = html.Div(children=[])
     if len(self._record["associations"]) > 0:
         div.children.append(html.H3("Associations"))
         div.children.append(html.Br())
     for assoc in self._record["associations"]:
         div.children.append(
             html.P("{}, {}".format(assoc["name"], assoc["type"])))
     div.children.append(html.Br())
     return div
Esempio n. 9
0
 def format_pulsar_paramters(self):
     pp = self._record["pulsar_parameters"]
     return html.Div(children=[
         html.H3("Pulsar Parameters"),
         html.Br(),
         html.P(["Period: {} ms".format(pp["period"])]),
         html.P(
             dcc.Markdown("Dispersion measure: {} pc cm<sup>-3</sup>".
                          format(pp["dm"]),
                          dangerously_allow_html=True)),
         html.P("Binary: {}".format(pp["binary"])),
         html.Br()
     ])
Esempio n. 10
0
 def format_discovery_parameters(self):
     dp = self._record["discovery_parameters"]
     return html.Div(children=[
         html.H3("Discovery details"),
         html.Br(),
         html.P("Discovery date: {}".format(dp["discovery_date"])),
         html.P("Observation date: {}".format(dp["observation_date"])),
         html.P("Observation band: {}".format(dp["discovery_band"])),
         html.P("Discovery S/N: {}".format(dp["discovery_snr"])),
         html.P("Pipeline: {}".format(dp["pipeline"])),
         html.P("Project: {}".format(dp["project"])),
         html.Br()
     ])
Esempio n. 11
0
def display_data_retrieval(value, tab):
    global client
    global client_thread
    if value == 'realtime':
        if tab == 'server':
            delete_residual_data(delete_streams=False)
            try:
                client.data_retrieval = False
                client_thread.close()
                client_thread = SLThread('Client SL Realtime', client)
                client_thread.start()
            except AttributeError:
                pass
        return []
    else:
        if tab == 'server':
            try:
                client.data_retrieval = True
                client_thread.close()
            except AttributeError:
                pass

        return [dcc.DatePickerSingle(id='date-picker-dcc', date=UTCDateTime().date,
                                     display_format='YYYY/MM/DD', number_of_months_shown=2,
                                     style={'display': 'inline-block', 'width': '40%'}),
                dbc.Input(id="input-hour", type="number", placeholder="HH", min=0, max=23, step=1,
                          style={'display': 'inline-block', 'width': '20%'}),
                dbc.Input(id="input-min", type="number", placeholder="MM", min=0, max=59, step=1,
                          style={'display': 'inline-block', 'width': '20%'}),
                dbc.Input(id="input-sec", type="number", placeholder="SS", min=0, max=59, step=1,
                          style={'display': 'inline-block', 'width': '20%'}),
                html.Br(),
                'Duration: ',
                dbc.Input(id="input-period", type="number", value=1, min=1, max=59, step=1,
                          style={'display': 'inline-block', 'width': "20%"}),
                dbc.Select(id='select-period',
                           options=[
                               {"label": "day", "value": "day"},
                               {"label": "hour", "value": "hour"},
                               {"label": "min", "value": "min"},
                               {"label": "sec", "value": "sec"},
                           ],
                           value='hour',
                           style={'display': 'inline-block', 'width':"20%"}),
                '  ',
                dbc.Button("Retrieve Data", id='retrieve-data-btn', color="success",
                           className="mb-1", n_clicks=0, style={'display': 'inline-block'}),
                html.Br()]
def selection():
    """ Drop downs for Comparison tab """
    selection_health = [
        html.Br(),
        dbc.Row([
            dbc.Col([
                'Group by:',
                dbc.Card(
                    dcc.Dropdown(
                        style={'height': '40px'},
                        id='group',
                        options=[{'label': 'Patient', 'value': 'Name'},
                                 {'label': 'Age', 'value': 'Age'},
                                 {'label': 'Sex', 'value': 'Sex'}],
                        value='Name',
                        clearable=False
                    ))], style={'height': '100%'}),
            dbc.Col([
                'First plot(x axis)',
                dbc.Card(
                    dcc.Dropdown(
                        id='Bar chart',
                        style={'height': '100%'},
                        options=[{'label': name, 'value': name} for name in label_bar],
                        value=label_bar[0],
                        clearable=False,
                    ))]),
            dbc.Col([
                'Second plot(y axis)',
                dbc.Card(dcc.Dropdown(
                    id='linear plot',
                    style={'height': '100%'},
                    options=[{'label': name, 'value': name} for name in label_linear],
                    value=label_linear[1],
                    clearable=False,
                ))]),
        ]),
    ]
    selection_workout = [html.Br(),
                         dbc.Row([dbc.Col(['Show heart rate during',
                                           dcc.Dropdown(
                                                id='Bar chart2',
                                                style={'height': '100%'},
                                                options=[{'label': name, 'value': name} for name in label_bar2],
                                                value='Walking',
                                                clearable=False,
                                            )])])]
    return selection_health, selection_workout
Esempio n. 13
0
def solar():
    return html.Div([
        html.Div([
            html.Div([], className="col-md-2"),
            html.Div([
                html.H2('US Solar Capacity'),
                html.Br(),
                dbc.Table.from_dataframe(
                    df, striped=True, bordered=True, hover=True),
                html.Div(id='output')
            ],
                     className="col-md-8"),
            html.Div([], className="col-md-2")
        ],
                 className='row'),
        dbc.Row([
            dbc.Col([
                dcc.Link("Global Warming",
                         href=spa.url_for('warming'),
                         className="btn btn-primary float-end")
            ],
                    md=12)
        ])
    ],
                    className="container-fluid")
Esempio n. 14
0
    def layout(self):

        voltage = self.get_numerical_input(
            kwarg_label="voltage",
            default=200,
            label="Voltage / kV",
            help_str=
            "The incident wavelength with which to generate the diffraction pattern, "
            "typically corresponding to a TEM microscope’s voltage.",
        )

        beam_direction = self.get_numerical_input(
            kwarg_label="beam_direction",
            default=[0, 0, 1],
            label="Beam Direction",
            help_str=
            "The direction of the electron beam fired onto the sample.",
            shape=(3, ),
            is_int=True,
        )

        # TODO: add additional kwargs for TemCalculator, or switch to an alternative solution

        return Columns([
            Column([Box(Loading(id=self.id("tem-plot")))], size=8),
            Column(
                [voltage, html.Br(), beam_direction],
                size=4,
            ),
        ], )
Esempio n. 15
0
def build_login_form(ctx):
    frm = SpaForm(ctx, 'loginFrm')

    def registerLink():
        return html.Div([
            "Don't have an account? ",
            dcc.Link("Create one", href=admin.url_for('register'))
        ],
                        className="mt-4 text-center")

    flash = frm.Alert(id='flash')
    email = frm.Input('Email',
                      id='email',
                      name='email',
                      type='email',
                      placeholder="Enter email")

    password = frm.PasswordInput("Password",
                                 name='password',
                                 id="password",
                                 placeholder="Enter password")
    password.children.insert(
        1,
        dcc.Link('Forgot Password?',
                 href=admin.url_for('forgot'),
                 className="float-end"))

    remember = frm.Checkbox("Remember me",
                            id='remember',
                            name='remember',
                            checked=True)
    button = frm.Button('Sign In', type='submit', id='btn')
    redirect = frm.Location(id='redirect', refresh=True)

    form = frm.Form(
        [flash, email, password, remember,
         html.Br(), button,
         registerLink()],
        id='login')

    @admin.callback([redirect.output.href, flash.output.children],
                    [form.input.form_data])
    def _form_submit(values):
        redirect = frm.NOUPDATE
        error = frm.NOUPDATE

        if ctx.isTriggered(form.input.form_data):
            email = values['email']
            password = values['password']
            remember = values['remember']
            valid = app.login_manager.login(email, password, remember)
            if valid:
                redirect = admin.url_for('user.profile')
            else:
                error = 'Please check your login details and try again.'

        return redirect, error

    layout = form_layout('Sign in', form)
    return html.Div([layout, redirect])
Esempio n. 16
0
def init_dashboard(server):
    dash_app = dash.Dash(
        server=server,
        routes_pathname_prefix="/",
        external_stylesheets=[dbc.themes.SUPERHERO],
    )
    
    dash_app.title = 'Covid-19 Dashboard'
    
    #lo Create Layout
    dash_app.layout = dbc.Container(
        [
            html.H1("USA Covid-19 Dashboard"),
            html.P(children=['Last updated: ',last_update], style={'text-align': 'right'}),
            html.Hr(),
            dbc.Tabs(
                [
                    dbc.Tab(label="Overview", tab_id="tab-1"),
                    dbc.Tab(label="Testing", tab_id="tab-3"),
                    dbc.Tab(label="Hospitalizations", tab_id="tab-4"),
                    dbc.Tab(label="Deaths", tab_id="tab-5"),
                    dbc.Tab(label="Vaccination", tab_id="tab-2"),
                    dbc.Tab(label="About", tab_id="tab-6"),
                    ],
                id = 'tabs',
                active_tab = 'tab-1',
                ),
            html.Div(id="tab-content", className="p-4"),
            html.Br(),
            html.Div(id="drop_figure"),
            ]
        )
    init_callbacks(dash_app)
    
    return dash_app.server
Esempio n. 17
0
def cards_view():
    """ card layout """
    cards = [
        dbc.Row([
            dbc.Col(dbc.Card([
                html.P("Resting Heart Rate Average", className="card-text"),
                html.H3(id='RestingHeartRate', className="card-title"),
            ],
                             body=True,
                             color="light",
                             style={'height': '100%'}),
                    sm=4),
            dbc.Col(dbc.Card([
                html.P("Walking Heart Rate Average", className="card-text"),
                html.H3(id='WalkingHeartRate', className="card-title"),
            ],
                             body=True,
                             color="light",
                             style={'height': '100%'}),
                    sm=4),
            dbc.Col(dbc.Card([
                html.P("Average Heart Rate", className="card-text"),
                html.H3(id='HeartRate_mean', className="card-title"),
            ],
                             body=True,
                             color="light",
                             style={'height': '100%'}),
                    sm=4)
        ]),
        html.Br(),
        dbc.Row([
            dbc.Col(dbc.Card([
                html.P("Steps", className="card-text"),
                html.H3(id='step', className="card-title"),
            ],
                             body=True,
                             color="light",
                             style={'height': '100%'}),
                    sm=4),
            dbc.Col(dbc.Card([
                html.P("Active Calories", className="card-text"),
                html.H3(id='ActivitySummary', className="card-title"),
            ],
                             body=True,
                             color="light",
                             style={'height': '100%'}),
                    sm=4),
            dbc.Col(dbc.Card([
                html.P("Exercise minutes ", className="card-text"),
                html.H3(id='Exercise_minute', className="card-title"),
            ],
                             body=True,
                             color="light",
                             style={'height': '100%'}),
                    sm=4)
        ])
    ]
    return cards
Esempio n. 18
0
    def update_results(n1, n2, nsum):
        context.calls = context.calls + 1
        context.callback_contexts.append(callback_context.triggered)

        return [
            "{} + {} = {}".format(n1, n2, nsum),
            html.Br(),
            "ctx.triggered={}".format(callback_context.triggered),
        ]
Esempio n. 19
0
 def display_click_data(clickdata):
     if clickdata is None:
         raise PreventUpdate
     points = clickdata['points'][0]
     hovertext = points['hovertext']
     hoverline = []
     for x in hovertext.split('<br>'):
         if x:
             hoverline.append(x)
             hoverline.append(html.Br())
         else:  # if blank line
             hoverline.append(html.Br())
     child_info = [
         html.Div('Click on variant to display its information'),
         html.Br(),
         html.Div(children=hoverline)
     ]
     return child_info
Esempio n. 20
0
def input_md5_demo(value, md5Value):
    if value:
        return [
            fac.AntdText('value: ', strong=True),
            value,
            html.Br(),
            fac.AntdText('md5Value: ', strong=True),
            md5Value
        ]
Esempio n. 21
0
    def contents_layout(self) -> html.Div:

        algorithm_choices = self.get_choice_input(
            label="Analysis method",
            kwarg_label="algorithm",
            state={"algorithm": "chemenv"},
            options=[
                {"label": "ChemEnv", "value": "chemenv"},
                {"label": "LocalEnv", "value": "localenv"},
                {"label": "Bonding Graph", "value": "bondinggraph"},
                {"label": "SOAP", "value": "soap"},
            ],
            help_str="Choose an analysis method to examine the local chemical environment. "
            "Several methods exist and there is no guaranteed correct answer, so try multiple!",
        )

        analysis = html.Div(id=self.id("analysis"))

        return html.Div([algorithm_choices, html.Br(), analysis, html.Br()])
Esempio n. 22
0
def test_grva008_shapes_not_lost(dash_dcc):
    # See issue #879 and pr #905
    app = Dash(__name__)

    fig = {"data": [], "layout": {"dragmode": "drawrect"}}
    graph = dcc.Graph(id="graph", figure=fig, style={"height": "400px"})

    app.layout = html.Div(
        [
            graph,
            html.Br(),
            html.Button(id="button", children="Clone figure"),
            html.Div(id="output", children=""),
        ]
    )

    app.clientside_callback(
        """
        function clone_figure(_, figure) {
            const new_figure = {...figure};
            const shapes = new_figure.layout.shapes || [];
            return [new_figure, shapes.length];
        }
        """,
        Output("graph", "figure"),
        Output("output", "children"),
        Input("button", "n_clicks"),
        State("graph", "figure"),
    )

    dash_dcc.start_server(app)
    button = dash_dcc.wait_for_element("#button")
    dash_dcc.wait_for_text_to_equal("#output", "0")

    # Draw a shape
    dash_dcc.click_and_hold_at_coord_fractions("#graph", 0.25, 0.25)
    dash_dcc.move_to_coord_fractions("#graph", 0.35, 0.75)
    dash_dcc.release()

    # Click to trigger an update of the output, the shape should survive
    dash_dcc.wait_for_text_to_equal("#output", "0")
    button.click()
    dash_dcc.wait_for_text_to_equal("#output", "1")

    # Draw another shape
    dash_dcc.click_and_hold_at_coord_fractions("#graph", 0.75, 0.25)
    dash_dcc.move_to_coord_fractions("#graph", 0.85, 0.75)
    dash_dcc.release()

    # Click to trigger an update of the output, the shape should survive
    dash_dcc.wait_for_text_to_equal("#output", "1")
    button.click()
    dash_dcc.wait_for_text_to_equal("#output", "2")

    assert dash_dcc.get_logs() == []
Esempio n. 23
0
 def get_references():
     return html.Div([
         html.Br(),
         html.Br(),
         html.H2("References "),
         html.Ul([
             html.Li(
                 html.A(
                     "Energy Usage Reports: Environmental awareness as part of algorithmic accountability",
                     href="https://arxiv.org/pdf/1911.08354.pdf",
                 )),
             html.Li(
                 html.A(
                     "Quantifying the Carbon Emissions of Machine Learning",
                     href="https://arxiv.org/pdf/1910.09700.pdf",
                 )),
         ]),
         html.Br(),
         html.Br(),
     ])
def getSummaryText(df, now):
    return [
        html.P([
            "These are the test results for the ",
            html.A("Traceability Interop Profile",
                   href="https://w3id.org/traceability/interoperability",
                   target="_blank"), " as of:" + now
        ]),
        html.P([
            "The highest current % of passed tests by a single provider is: ",
            str(df['Passing'].min()),
            html.Br(),
            "The lowest is: ",
            str(df['Passing'].max()),
            html.Br(),
            "Across all providers the average % of passed tests is: ",
            "{:.1%}".format(
                df['Passing'].str.replace("\%", "").astype(float).mean() /
                100),
        ])
    ]
Esempio n. 25
0
    def layout(self):

        return html.Div([
            html.Div(
                "Transform your crystal structure using the power of pymatgen.",
                className="mpc-panel-description",
            ),
            self._sub_layouts["choices"],
            html.Br(),
            html.Div(id=self.id("error")),
            html.Div(id=self.id("transformation_options")),
        ])
Esempio n. 26
0
 def get_global_comparison(self):
     return html.Div([
         html.Br(),
         html.Br(),
         html.H2(
             "Global Benchmarks",
             style={
                 "textAlign": "center",
                 "paddingLeft": "15%",
                 "marginLeft": "-15%",
             },
         ),
         html.Br(),
         html.Br(),
         dcc.Tabs(
             id="global_benchmarks",
             value="emissions_tab",
             children=[self.get_emissions_tab(),
                       self.get_energy_mix_tab()],
         ),
     ])
def update_model(*args):
    """
    Set up reduced model
    """
    fixed_parameters = list(args)
    app.update_model(fixed_parameters)

    output = []
    for i in range(len(parameters_name)):
        output.append(parameters_name[i] + ' = {}'.format(fixed_parameters[i]))
        output.append(html.Br())

    return html.P(output)
Esempio n. 28
0
def form_container(title, fields, id=None):

    if id:
        form = dhc.Form(fields, id=id, preventDefault=True)
    else:
        form = dhc.Form(fields, preventDefault=True)

    return html.Div(
        [
            html.Div(
                [
                    html.Div(className="col-md-2"),
                    html.Div(
                        [
                            html.Div(
                                [
                                    html.Div(
                                        [
                                            html.Br(),
                                            html.H4(title),
                                            html.Br(),
                                            form,
                                            html.Br(),
                                        ],
                                        className="card-body",
                                    )
                                ],
                                className="card",
                            )
                        ],
                        className="col-md-8",
                    ),
                    html.Div(className="col-md-2"),
                ],
                className="row",
            )
        ],
        className="container-fluid",
    )
Esempio n. 29
0
        def update_localenv_analysis(graph):

            if not graph:
                raise PreventUpdate

            graph = self.from_data(graph)

            return html.Div(
                [
                    str(_get_local_order_parameters(graph, 0)),
                    html.Br(),
                    html.Small("This functionality is still under development."),
                ]
            )
Esempio n. 30
0
 def get_cloud_emissions_comparison():
     return html.Div(
         dbc.Col(
             [
                 html.Br(),
                 html.Br(),
                 html.H2(
                     [
                         "Emissions Across ",
                         html.Strong(
                             id="cloud_provider_name",
                             style={
                                 "fontWeight": "normal",
                                 "color": "green"
                             },
                         ),
                         " Regions",
                     ],
                     style={
                         "textAlign": "center",
                         "marginLeft": "12%"
                     },
                 ),
                 dcc.Graph(id="cloud_emissions_barchart"),
                 html.Br(),
                 html.Div(
                     id="cloud_recommendation",
                     style={
                         "marginLeft": "12%",
                         "textAlign": "center"
                     },
                 ),
             ],
             id="cloud_emissions_comparison_component",
         ),
         style={"marginLeft": "-12%"},
     )