예제 #1
0
def get_item_hud(hud_title='LCL FORECAST ANALYSIS', hud_1_0='', hud_1_1='') \
        -> Container:
    """
    :param hud_title: str top of HUD
    :param hud_1_0: str Byline Position 1
    :param hud_1_1: str Byline Position 2
    
    :param
    hud_1_2: str
    :return: 
    Container: 'item-hud-container'
        Row
            Container:'item-hud-title-container'
                Col
                    H1: 'hud-title'
        Container: 'item-hud-byline-container'
            Row 
                Navbar: item-hud-bar'
                    NavItem:
                        H2: 'hud-1-0'
                        H2: hud-1-1'
            Row
                Tabs: 'table-tabs-nav'
                    Tab: 'tab-all
    """
    layout = Container(
        fluid=True,
        id='item-hud-container',
        children=[
            Row(
                Container(
                    id='item-hud-title-container',
                    children=[Col(H1(id='hud-title', children=hud_title))])),
            Container(
                id='item-hud-byline-container',
                style=VISIBILITY_HIDDEN,
                children=[
                    Row([
                        Navbar(id='item-hud-bar',
                               children=[
                                   NavItem(H2(hud_1_0, id='hud-1-0')),
                                   NavItem(H2(hud_1_1, id='hud-1-1'))
                               ])
                    ]),
                    Row([
                        Tabs(
                            id='table-tabs-nav',
                            children=[Tab(tab_id='tab-all', label='All')],
                        )
                    ],
                        id='item-hub-tabs-row')
                ]),
            Div(id='datasource-1'),
            Div(id='datasource-2')
        ])
    return layout
예제 #2
0
 def get_html(self) -> List[ComponentMeta]:
     """Initializes the header dash html
     """
     return [
         H2(self.content["new-admissions-title"]),
         Markdown(self.content["new-admissions-text"]),
         Graph(id="new-admissions-graph"),
         Table(id="new-admissions-table"),
         H2(self.content["admitted-patients-title"]),
         Markdown(self.content["admitted-patients-text"]),
         Graph(id="admitted-patients-graph"),
         Table(id="admitted-patients-table"),
     ]
예제 #3
0
def _generate_body(asset_name="", files=[]):
    elements = []

    elements.append(H2(" ".join(asset_name.split("-")).title()))

    df_records = groupby(get_dataframes(files), lambda x: ".".join(x["record_path"].split(".")[:-2]))

    for k, recs in df_records.items():
        # Header
        if k == "period":
            continue
        elements.append(H3(k))
        elements.append(Div(len(recs)))
        data = None
        if len(recs) == 1:
            # Data Vis: Chart or Table
            data = recs[0]["data"]
        elif len(recs) == 2:
            df_num_idx = 0 if _is_series_numeric(recs[0]["data"]["value"]) else 1
            df_str_idx = 1 - df_num_idx

            df_num = recs[df_num_idx]["data"]
            df_str = _reshape_dataframe_narrow_to_wide(recs[df_str_idx]["data"])
            join_keys = list(df_num.columns.intersection(df_str.columns))
            data = df_str.join(df_num.set_index(join_keys), on=join_keys, how="outer")

        if data is not None:
            if "value" in data.columns and _is_series_numeric(data["value"]) and "period" in data.columns:
                elements.append(_generate_chart(data, asset_name + k))
            else:
                elements.append(_generate_table(data))

    return elements
def create_slide_0() -> Div:
    """Returns overview slide with agenda"""
    return dbc.Col([
        H2("Agenda"),
        H5(Ol([
            Li("Bullet Point 1", className="mt-5"),
            Li("Bullet Point 2"),
            Li("Bullet Point 3"),
            Li("Bullet Point 4"),
        ], className="mt-4 list-spacing"))
    ], width=12, className="p-5")
def create_slide_1() -> Div:
    """Returns overview slide with agenda"""
    return dbc.Col([
        H2("Tabs example", className="mb-4"),
        dbc.Card([
            dbc.CardHeader(
                dbc.Tabs([
                    dbc.Tab(label="Tab 1", tab_id="slide1-tab-1"),
                    dbc.Tab(label="Tab 2", tab_id="slide1-tab-2"),
                    dbc.Tab(label="Tab 3", tab_id="slide1-tab-3"),
                ],
                         id="slide1-tabs",
                         card=True,
                         active_tab="slide1-tab-1")),
            dbc.CardBody(Loading(id="slide1-tab-content"), className="mt-2")
        ]),
    ],
                   width=12,
                   className="p-5")
예제 #6
0
def generate_layout(headers, reports, models):
    """Generates report table and returns it
    headers - texts in headers in format {metric_internal_name: metric_ui_name}
    reports - DB data in format [(id, {metric: value})
    models - information about models in format [(id, name, type)]"""

    if not reports: return Div()

    return Div([
        H2("Метрики"),
        Table(
            [Tr(
                [Th("Name")] +
                [Th(headers[metric]) for metric in reports[0][1]]
            )] +
            [Tr(
                [Td([m[1] for m in models if m[0] == report[0]][0])] +
                [Td(round(value,4)) for value in report[1].values()]
            )
             for report in reports]
        )
    ])
예제 #7
0
 def html_instruction_list(self) -> typing.List:
     return [
         H1("BET ETF Calculator"),
         Ul(
             [
                 Li("Andrei Răduță"),
                 Li("*****@*****.**"),
                 Li(
                     Link(
                         children="https://github.com/andreiraduta11/bet-etf",
                         href="https://github.com/andreiraduta11/bet-etf",
                     )
                 ),
             ]
         ),
         H2("Instructions:"),
         Ol(
             [
                 Li("Set the size of the list of symbols."),
                 Li("Set the sum you are going to invest."),
                 Li("Set the specific transaction fee for your grid."),
                 Li(
                     [
                         "Set your current holdings for each symbol ",
                         I("(no information is stored)."),
                     ]
                 ),
                 Li(
                     (
                         "The buying price is the last price (at the specified "
                         "time). Feel free to change it."
                     )
                 ),
                 Li("Place your orders. The order values should be the same."),
             ]
         ),
         I(id="symbols_time"),
     ]
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={
                            'paddingTop': 200,
                            'paddingBottom': 200
                        },
                        type='dot'),
            Div([
                P('This is the text field word cloud generator. Simply copy and paste the text into the box below.'
                  ),
                Div([
                    Div([
예제 #9
0
 def get_html(self) -> List[ComponentMeta]:
     """Initializes the header dash html
     """
     today = date.today().strftime(self.content["date-format"])
     return [
         Container(
             className="mt-5",
             children=[
                 H2(self.content["new-admissions-title"]),
                 Markdown(self.content["new-admissions-text"]),
             ]
         ),
         Container(fluid=True, children=Graph(id="new_admissions_graph")),
         Container([
             A(
                 self.content["download-text"],
                 id="new_admissions_download",
                 download="admissions_{}.csv".format(today),
                 href="",
                 target="_blank",
                 className="btn btn-sm btn-info",
             ),
             Div(
                 children=Button(
                     "Lock Zoom", 
                     id="new_admissions_lock_zoom", 
                     color="info", 
                     outline=False,
                     className="btn btn-sm"
                     ),
                 style={"display": "inline-block", "padding": 10}
             ),
             Div(
                 className="row justify-content-center",
                 children=Div(
                     id="new_admissions_table_container",
                     className="col-auto",
                     children=Table(
                         id="new_admissions_table",
                         className="table-responsive mx-auto"
                     ),
                 ),
             ),
         ]),
         Container(
             className="mt-5",
             children=[
                 H2(self.content["admitted-patients-title"]),
                 Markdown(self.content["admitted-patients-text"]),
             ],
         ),
         Container(fluid=True, children=Graph(id="admitted_patients_graph")),
         Container([
             A(
                 self.content["download-text"],
                 id="admitted_patients_download",
                 download="census_{}.csv".format(today),
                 href="",
                 target="_blank",
                 className="btn btn-sm btn-info",
             ),
             Div(
                 children=Button(
                     "Lock Zoom", 
                     id="admitted_patients_lock_zoom", 
                     color="info", 
                     outline=False, 
                     className="btn btn-sm"
                     ),
                 style={"display": "inline-block", "padding": 10}
             ),
             Div(
                 className="row justify-content-center",
                 children=Div(
                     id="admitted_patients_table_container",
                     className="col-auto",
                     children=Table(
                         id="admitted_patients_table",
                         className="table-responsive"
                     ),
                 ),
             ),
         ]),
         Container(
             className="mt-5",
             children=[
                 H2(self.content["SIR-title"]),
                 Markdown(self.content["SIR-text"]),
             ],
         ),
         Container(fluid=True, children=Graph(id="SIR_graph")),
         Container([
             A(
                 self.content["download-text"],
                 id="SIR_download",
                 download="SIR_{}.csv".format(today),
                 href="",
                 target="_blank",
                 className="btn btn-sm btn-info my-4",
             ),
             Div(
                 children=Button(
                     "Lock Zoom", 
                     id="SIR_lock_zoom", 
                     color="info", 
                     outline=False, 
                     className="btn btn-sm"
                     ),
                 style={"display": "inline-block", "padding": 10}
             ),
             Div(
                 className="row justify-content-center",
                 children=Div(
                     id="SIR_table_container",
                     className="col-auto",
                     children=Table(
                         id="SIR_table",
                         className="table-responsive"
                     ),
                 ),
             ),
         ])
     ]
예제 #10
0
def make_word_cloud(imagemaskurl, relative_scaling, nwords, text, title,
                    customstopwords, width, height, color, colormap, maxfont,
                    minfont, scale):
    if imagemaskurl is not None and imagemaskurl != '':
        # imgstr = re.search(r'base64,(.*)', imagemask).group(1)
        try:
            if imagemaskurl.startswith('data:image'):
                imgstr = re.search(r'base64,(.*)', imagemask).group(1)
                b = base64.b64decode(imgstr)
            else:
                r = requests.get(imagemaskurl)
                b = r.content
            image_bytes = io.BytesIO(b)
            im = Image.open(image_bytes).convert('RGBA')
            canvas = Image.new('RGBA', im.size, (255, 255, 255, 255))
            canvas.paste(im, mask=im)
            mask = np.array(canvas)
            width, height = im.size
        except:
            mask = None
            text = 'Invalid Image Mask!'
    else:
        mask = None
    from wordcloud import STOPWORDS
    STOPWORDS = list(STOPWORDS)

    for word in customstopwords:
        STOPWORDS.append(word)
        STOPWORDS.append(word + 's')
        STOPWORDS.append(word + "'s")
    if color == '':
        color = None
    cloud = WordCloud(width=width, height=height, mask=mask, background_color=color,
                      stopwords=STOPWORDS, max_words=nwords, colormap=colormap,
                      max_font_size=maxfont, min_font_size=minfont,
                      random_state=42, scale=scale, mode='RGBA',
                      relative_scaling=relative_scaling).generate(text)
    try:
        coloring = ImageColorGenerator(mask)
        cloud.recolor(color_func=coloring)
    except:
        pass
    image = cloud.to_image()

    byte_io = io.BytesIO()
    image.save(byte_io, 'PNG')
    byte_io.seek(0)
    data_uri = base64.b64encode(byte_io.getvalue()).decode('utf-8').replace('\n', '')
    src = 'data:image/png;base64,{0}'.format(data_uri)
    x = np.array(list(cloud.words_.keys()))
    y = np.array(list(cloud.words_.values()))
    order = np.argsort(y)[::-1]
    x = x[order]
    y = y[order]
    trace = go.Bar(x=x, y=y)
    layout = go.Layout(margin=go.Margin(l=10, r=00),
                       title='Relative frequency of words/bigrams')
    fig = go.Figure(data=[trace], layout=layout)
    children = [
        H2(title, className='card-title'),
        Img(src=src, width=image.size[0], height=image.size[1],
            style={'maxWidth': '100%', 'height': 'auto',
                   'margin': '0 auto', 'display': 'block'}),
        # Details([
        #     Summary('View Frequency Plot'),
        #     dcc.Graph(id='word-freq', figure=fig, config={'displayModeBar': False})
        # ])
    ]

    return children
예제 #11
0
def get_layout(app):
    row_0 = Div([
        H2("Upload to Database (excel file)", style={'textAlign': 'left'}),
        Upload(
            id='upload-data',
            children=Div(['Drag and Drop or ',
                          A('Select Files')]),
            style={
                'width': '100%',
                'height': '60px',
                'lineHeight': '60px',
                'borderWidth': '1px',
                'borderStyle': 'dashed',
                'borderRadius': '5px',
                'textAlign': 'center',
                'margin': '10px'
            },
            # Allow multiple files to be uploaded
            multiple=False),
        Loading(
            id="loading",
            children=[Div(id='output-data-upload')],
            type="default",
        ),
    ])
    row_1 = Div([
        Div([
            H2("Text input", style={'textAlign': 'left'}),
            RadioItems(id='radio1',
                       options=[{
                           'label': 'Partial match',
                           'value': 'PMATCH'
                       }, {
                           'label': 'Exact match',
                           'value': 'EMATCH'
                       }],
                       value='EMATCH',
                       labelStyle={
                           'display': 'inline-block',
                       }),
            Input(id="input1", type="text", placeholder="Query"),
            Br(),
            Button('Start text search', id='button')
        ],
            className='col-6'),
        Div([
            H2("Search field", style={'textAlign': 'left'}),
            RadioItems(id='radio2',
                       options=[{
                           'label': 'Chemical name',
                           'value': 'NAME'
                       }, {
                           'label': 'CAS Number',
                           'value': 'CAS'
                       }, {
                           'label': 'IASO Barcode No.',
                           'value': 'BAR'
                       }],
                       value='NAME',
                       labelStyle={
                           'display': 'inline-block',
                       }),
        ],
            className='col-6')
    ],
                className='row')
    row_2 = Div([
        Div([
            H2("Graphical search type", style={'textAlign': 'left'}),
            RadioItems(id='radio3',
                       options=[{
                           'label': 'Similarity ',
                           'value': 'SIM'
                       }, {
                           'label': 'Substructural ',
                           'value': 'SUB'
                       }, {
                           'label': 'Exact ',
                           'value': 'EX'
                       }],
                       value='SIM',
                       labelStyle={
                           'display': 'inline-block',
                       }),
            DashMarvinJS(id='editor',
                         marvin_url=app.get_asset_url('mjs/editor.html'),
                         marvin_width='100%')
        ],
            className='col-6'),
        Div([
            H2("Search results", style={'textAlign': 'left'}),
            DataTable(
                id='table',
                columns=fields1,
                fixed_rows={
                    'headers': True,
                    'data': 0
                },
                row_selectable='single',
                style_data={
                    'whiteSpace': 'normal',
                    'height': 'auto',
                    'width': 'auto'
                },
                style_table={
                    'overflowY': 'hidden',
                    'overflowX': 'hidden',
                    'margin-left': '0px'
                },
                style_cell={
                    'textAlign': 'left',
                    'padding': '5px',
                    'height': 'auto',
                    'padding-left': '17px',
                    'whiteSpace': 'normal',
                    'minWidth': '10px',
                    'maxWidth': '150px'
                },
                style_as_list_view=True,
                style_cell_conditional=[
                    {
                        'if': {
                            'column_id': 'Picture'
                        },
                        'width': '60%'
                    },
                    {
                        'if': {
                            'column_id': 'Brutto formula'
                        },
                        'width': '10%'
                    },
                    {
                        'if': {
                            'column_id': 'Chemical name'
                        },
                        'width': '15%'
                    },
                    {
                        'if': {
                            'column_id': 'CAS No.'
                        },
                        'width': '10%'
                    },
                ],
            )
        ],
            className='col-6')
    ],
                className='row')
    row_3 = DataTable(
        id='table2',
        columns=fields2,
        fixed_rows={
            'headers': True,
            'data': 0
        },
        #row_selectable='single',
        editable=True,
        row_deletable=True,
        style_data={
            'whiteSpace': 'normal',
            'height': 'auto'
        },
        style_table={
            'maxHeight': '500px',
            'overflowY': 'hidden',
            'overflowX': 'hidden',
            'margin-left': '0px'
        },
        style_cell={
            'textAlign': 'left',
            'padding': '10px',
            'padding-left': '20px',
            'height': 'auto',
            'whiteSpace': 'normal',
            'minWidth': '120px',
            'width': '150px'
        },
        #style_cell_conditional=[
        #    {'if': {'column_id': 'Quantity'},
        #     'width': '150px'},
        #   {'if': {'column_id': 'Quantity unit'},
        #     'width': '150px'},
        #],
        style_as_list_view=True)
    row_4 = Div([
        Button('Add Row', id='addrow', n_clicks=0),
        Button('Submit changes', id='submit', n_clicks=0),
        ConfirmDialog(
            id='confirm',
            message=
            'All changes will be applied from now! Are you sure you want to continue?',
        )
    ])

    layout = Div([
        H1("Chemicals Storage", style={'textAlign': 'center'}), row_0,
        Hr(), row_1,
        Hr(), row_2,
        Hr(), row_3,
        Hr(), row_4
    ])
    return layout
def create_slide_2() -> Div:
    """Returns overview slide with agenda"""
    return dbc.Col([
        H2("Plot example", className="mb-4"),
        Div(id="slide2-plot"),
    ], width=12, className="p-5")
 def get_html(self) -> List[ComponentMeta]:
     """Initializes the header dash html
     """
     today = date.today().strftime(self.content["date-format"])
     return [
         H2(self.content["new-admissions-title"]),
         Markdown(self.content["new-admissions-text"]),
         Graph(id="new_admissions_graph"),
         A(
             self.content["download-text"],
             id="new_admissions_download",
             download="admissions_{}.csv".format(today),
             href="",
             target="_blank",
             className="btn btn-sm btn-info my-2",
         ),
         Div(
             className="row justify-content-center",
             children=Div(
                 id="new_admissions_table_container",
                 className="col-auto",
                 children=[
                     Table(id="new_admissions_table",
                           className="table-responsive"),
                 ],
             ),
         ),
         H2(self.content["admitted-patients-title"]),
         Markdown(self.content["admitted-patients-text"]),
         Graph(id="admitted_patients_graph"),
         A(
             self.content["download-text"],
             id="admitted_patients_download",
             download="census_{}.csv".format(today),
             href="",
             target="_blank",
             className="btn btn-sm btn-info my-4",
         ),
         Div(
             className="row justify-content-center",
             children=Div(
                 id="admitted_patients_table_container",
                 className="col-auto",
                 children=[
                     Table(id="admitted_patients_table",
                           className="table-responsive"),
                 ],
             ),
         ),
         H2(self.content["SIR-title"]),
         Markdown(self.content["SIR-text"]),
         Graph(id="SIR_graph"),
         A(
             self.content["download-text"],
             id="SIR_download",
             download="SIR_{}.csv".format(today),
             href="",
             target="_blank",
             className="btn btn-sm btn-info my-4",
         ),
         Div(
             className="row justify-content-center",
             children=Div(
                 id="SIR_table_container",
                 className="col-auto",
                 children=[
                     Table(id="SIR_table", className="table-responsive"),
                 ],
             ),
         ),
     ]