コード例 #1
0
ファイル: plots.py プロジェクト: marco-mariotti/treedex
def make_scatter_menu(id_index): #, colnames, current_options):
    print('** make_scatter_menu')

    return dbc.Offcanvas(
        [html.P("Dropdowns for setting data input, X, Y, color, size:"),

         dbc.Row([dbc.Col('Title:'),
                  dbc.Col(dcc.Input(id={'type': 'scatter_inputtext', 'index': id_index, 'property': 'title'},
                                    placeholder='Enter title here',
                                    #value=''),
                                    ),
                          width=7)],
                 justify='start'),

         dbc.Row([dbc.Col('Data:'),
                  dbc.Col(dcc.Dropdown(id={'type': 'scatter_dropdown', 'index': id_index, 'property': 'dataset'},
                                       #options=[dict(label='Lifehistory', value='Lifehistory'),
                                       #         dict(label='Load file...', value='_load_file')],
                                       #value='Lifehistory'
                                       ),
                          width=7)],
                 justify='start'),

         dbc.Row([dbc.Col('X:'),
                  dbc.Col(dcc.Dropdown(id={'type': 'scatter_dropdown', 'index': id_index, 'property': 'x'}, ),
                                       #options=[{'label': c, 'value': c} for c in df_records[0].keys()],
                                       #value='logAdultWeight'),
                          width=7)],
                 justify='start'),
         dbc.Row([dbc.Col('Y:'),
                  dbc.Col(dcc.Dropdown(id={'type': 'scatter_dropdown', 'index': id_index, 'property': 'y'},),
                                       #options=[{'label': c, 'value': c} for c in df_records[0].keys()],
                                       #value='MaxLifespan'),
                          width=7)],
                 justify='start'),

         # dbc.Row([dbc.Col('Color:'),
         #          dbc.Col(dcc.Dropdown(id={'type':'scatter_dropdown', 'index':id_index, 'property':'color'},
         #                               options=[{'label': c, 'value': c} for c in df.columns]),
         #                  width=7)],
         #         justify='start'),
         #
         # dbc.Row([dbc.Col('Size:'),
         #          dbc.Col(dcc.Dropdown(id={'type':'scatter_dropdown', 'index':id_index, 'property':'size'},
         #                               options=[{'label': c, 'value': c} for c in df.columns]),
         #                  width=7)],
         #         justify='start'),
         dbc.Row(dbc.Col(' ')),
         dbc.Row(dbc.Col(
             dbc.Button("Apply", size="sm", n_clicks=0,
                        id={'type': 'scatter_configure_ok', 'index': id_index}),
             class_name="g-2"))

         ],
        title="Menu: Scatter item",
        is_open=False,
        id={'type': 'scatter_menu', 'index': id_index}
    )
コード例 #2
0
 def add_content(self):
     """
     """
     if self.html_layout:
         return html.Div(
             id="div-main",
             children=[
                 dcc.Store(id="control-panel"),
                 dcc.Location(id="url", refresh=False),
                 dbc.Row(id="row-navbar",
                         class_name="g-0",
                         children=[
                             self._add_navbar(),
                         ]),
                 dcc.Loading(
                     dbc.Offcanvas(class_name="w-25",
                                   id="offcanvas-metadata",
                                   title="Detailed Information",
                                   placement="end",
                                   is_open=False,
                                   children=[dbc.Row(id="row-metadata")])),
                 dbc.Row(id="row-main",
                         class_name="g-0",
                         children=[
                             self._add_ctrl_col(),
                             self._add_plotting_col(),
                         ])
             ])
     else:
         return html.Div(id="div-main-error",
                         children=[
                             dbc.Alert(
                                 [
                                     "An Error Occured",
                                 ],
                                 color="danger",
                             ),
                         ])
コード例 #3
0
import dash_bootstrap_components as dbc
from dash import html

from .util import make_subheading

COOKIE = "https://todaysmama.com/.image/t_share/MTU5OTEwMzkyMDIyMTE1NzAz/cookie-monster.png"  # noqa
offcanvas = html.Div(
    [
        make_subheading("Offcanvas", "offcanvas"),
        html.P([
            dbc.Button("Show the cookie monster", id="offcanvas-button"),
            dbc.Offcanvas(
                html.Img(src=COOKIE, style={"width": "100%"}),
                title="Cookies!",
                id="offcanvas",
                is_open=False,
            ),
        ]),
    ],
    className="mb-4",
)
コード例 #4
0
import dash_bootstrap_components as dbc
from dash import Input, Output, State, html

offcanvas = html.Div(
    [
        dbc.Button(
            "Open scrollable offcanvas",
            id="open-offcanvas-scrollable",
            n_clicks=0,
        ),
        dbc.Offcanvas(
            html.P("The contents on the main page are now scrollable."),
            id="offcanvas-scrollable",
            scrollable=True,
            title="Scrollable Offcanvas",
            is_open=False,
        ),
    ]
)


@app.callback(
    Output("offcanvas-scrollable", "is_open"),
    Input("open-offcanvas-scrollable", "n_clicks"),
    State("offcanvas-scrollable", "is_open"),
)
def toggle_offcanvas_scrollable(n1, is_open):
    if n1:
        return not is_open
    return is_open
コード例 #5
0
    brand="Multi Page App Plugin Demo",
    color="primary",
    dark=True,
    className="mb-2",
)

sidebar_button = dbc.Button(html.I(className="fa fa-bars"), id="sidebar-btn")
sidebar = dbc.Offcanvas(
    dbc.Nav(
        [html.H3("Chapters")] + [
            dbc.NavLink(
                [
                    html.I(className=page["icon"]),
                    html.Span(page["name"], className="ms-2"),
                ],
                href=page["path"],
                active="exact",
            ) for page in dash.page_registry.values()
            if page["path"].startswith("/chapter")
        ],
        vertical=True,
        pills=True,
    ),
    id="offcanvas",
)

app.layout = dbc.Container(
    [
        navbar,
        dbc.Row([
            dbc.Col([sidebar_button], width=1),
            dbc.Col([sidebar, dl.plugins.page_container]),
コード例 #6
0
            value="start",
            inline=True,
        ),
    ],
    className="mb-2",
)

offcanvas = html.Div(
    [
        placement_selector,
        dbc.Button(
            "Open Offcanvas", id="open-offcanvas-placement", n_clicks=0
        ),
        dbc.Offcanvas(
            html.P("Some offcanvas content..."),
            id="offcanvas-placement",
            title="Placement",
            is_open=False,
        ),
    ]
)


@app.callback(
    Output("offcanvas-placement", "is_open"),
    Input("open-offcanvas-placement", "n_clicks"),
    [State("offcanvas-placement", "is_open")],
)
def toggle_offcanvas(n1, is_open):
    if n1:
        return not is_open
    return is_open
コード例 #7
0
import dash_bootstrap_components as dbc
from dash import Input, Output, State, html

offcanvas = html.Div([
    dbc.Button("Open Offcanvas", id="open-offcanvas", n_clicks=0),
    dbc.Offcanvas(
        html.P("This is the content of the Offcanvas. "
               "Close it by clicking on the close button, or "
               "the backdrop."),
        id="offcanvas",
        title="Title",
        is_open=False,
    ),
])


@app.callback(
    Output("offcanvas", "is_open"),
    Input("open-offcanvas", "n_clicks"),
    [State("offcanvas", "is_open")],
)
def toggle_offcanvas(n1, is_open):
    if n1:
        return not is_open
    return is_open
コード例 #8
0
    def make_cyclometry_config(self, c_activity: CActivity) -> html.Div:

        button = dbc.Button("✎",
                            id="btn_open_cyclometry_config_offcanvas",
                            size='sm',
                            color='secondary',
                            n_clicks=0)
        config_view = dbc.Table(
            [
                html.Tr([
                    html.Td(f"AWC {c_activity.awc} J"),
                    html.Td(f"SWC {c_activity.swc} J"),
                    html.Td(dbc.Badge(
                        button,
                        color="secondary",
                    ), rowSpan=2)
                ]),
                html.Tr([
                    html.Td(f"CP {c_activity.cp} W"),
                    html.Td(f"GP {c_activity.gp} W"),
                ]),
            ],
            bordered=False,
            size='sm',
        )

        def make_inputs() -> dbc.Form:
            inputs = []
            for k, v in {
                    'AWC': c_activity.awc,
                    'SWC': c_activity.swc,
                    'CP': c_activity.cp,
                    'GP': c_activity.gp
            }.items():
                input = html.Div([
                    dbc.Label(k),
                    dbc.Input(type="number", id=f"inpt_{k}", placeholder=v),
                ])
                inputs.append(input)
            return dbc.Form(inputs, id="cyclometry_config_form")

        offcanvas = html.Div([
            config_view,
            dbc.Offcanvas(
                [
                    html.
                    P("Set Cyclometry parameters in order to request activity recalculation"
                      ),
                    make_inputs(),
                    html.Br(),
                    dbc.Button("Save",
                               id="btn_save_cyclometry_config_offcanvas",
                               n_clicks=0)
                ],
                id="cyclometry_config_offcanvas",
                placement='end',
                title="Configuration",
                is_open=False,
            )
        ])
        return offcanvas
コード例 #9
0
import dash
from dash import dcc, html, Output, Input, State
import dash_labs as dl
import dash_bootstrap_components as dbc

app = dash.Dash(__name__,
                plugins=[dl.plugins.pages],
                external_stylesheets=[dbc.themes.BOOTSTRAP])

offcanvas = html.Div([
    dbc.Button("Explore", id="open-offcanvas", n_clicks=0),
    dbc.Offcanvas(
        dbc.ListGroup([
            dbc.ListGroupItem(page["name"], href=page["path"])
            for page in dash.page_registry.values()
            if page["module"] != "pages.not_found_404"
        ]),
        id="offcanvas",
        is_open=False,
    ),
],
                     className="my-3")

app.layout = dbc.Container(
    [offcanvas, dl.plugins.page_container],
    fluid=True,
)


@app.callback(
    Output("offcanvas", "is_open"),
コード例 #10
0
            ],
            inline=True,
            value=True,
        ),
    ],
    className="mb-2",
)

offcanvas = html.Div([
    backdrop_selector,
    dbc.Button("Open backdrop offcanvas",
               id="open-offcanvas-backdrop",
               n_clicks=0),
    dbc.Offcanvas(
        html.P("Here is some content..."),
        id="offcanvas-backdrop",
        title="Offcanvas with/without backdrop",
        is_open=False,
    ),
])


@app.callback(
    Output("offcanvas-backdrop", "backdrop"),
    [Input("offcanvas-backdrop-selector", "value")],
)
def select_backdrop(backdrop):
    return backdrop


@app.callback(
    Output("offcanvas-backdrop", "is_open"),