Exemple #1
0
         html.Img(src=app.get_asset_url("imgs/logo_wide.svg"), alt="COVID-19 Drugs Networker", style={"width":"100%"}),
     ], xs=10, lg=6, align="center", style={"position":"relative","z-index":"1"}),
     dbc.Col([
         html.P("Visualize and Analyze Networks about Drugs and Targets Related to COVID-19", style={"text-align":"center","font-size":"x-large","font-weight":"bold","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem"}),
         html.P("COVIDrugNet is a free and open web tool", style={"text-align":"center","font-size":"large","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem", "margin-bottom":0}),
         html.P("based on networks and designed to support the exploration and investigation of the landscape of medicines currently in clinical trial for the treatment of COVID-19", style={"text-align":"center","font-size":"large","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem", "margin-bottom":0}),
         html.P(["(according to ",html.A("DrugBank Dashboard dedicated to COVID-19", href="https://go.drugbank.com/covid-19", target="_blank", style={"color":"black"}),")"], style={"text-align":"center","font-size":"medium","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem"})
     ], xs=10, lg=3, align="center", style={"position":"relative","z-index":"1"})
 ], justify="center", align="center", style={"padding-top":"7.5vh", "padding-bottom":"7.5vh"}),
 # html.Center(html.H4("Visualize and Analyze Networks about Drugs and Targets Related to COVID-19")),
 dbc.Row([
     dbc.Col([
         html.A([
             html.Center([
                 dbc.Card([
                     dbc.CardImg(src=app.get_asset_url("imgs/drug_target.png"), top=True, style={"width":"80%", "margin":"auto"}, alt="Drug-Target Network"),
                     dbc.CardBody(html.H4(html.Strong("Drug-Target Network"), className="card-title", style={"color":"#707070"})),
                     dbc.Container([
                         html.H1(["Drug-Target",html.Br(),"Bipartite Network"], className="fancy-hover-title"),
                         html.H3("It is the main network and it is built connecting drugs from the COVID-19 Dashboard of DrugBank and their reported targets.", className="fancy-hover-text")
                     ], className="fancy-hover-bg")
                 ], color="light", style={"box-shadow":"0rem 0rem 0.25rem lightgrey", "border-radius": "2rem"})
             ])
         ], href="/covidrugnet/drug_target", style={"text-decoration":"none"}, className="home-card"),
     ], xs=10, md=3),
     dbc.Col([
         html.A([
             html.Center([
                 dbc.Card([
                     dbc.CardImg(src=app.get_asset_url("imgs/drug_projection.png"), top=True, style={"width":"80%", "margin":"auto"}, alt="Drug Projection"),
                     dbc.CardBody(html.H4(html.Strong("Drug Projection"), className="card-title", style={"color":"#707070"})),
Exemple #2
0
# ----------------------------------------------------------------------------------------------
df_table_content = pd.DataFrame(
    {
        "Image File Name": [],
        "Class": [],
    }
)
current_img_index = 0
progress_percentage = 0

image_related_cards = dbc.CardGroup(
    [
        dbc.Card(
            [
                dbc.CardImg(top=True, id="eye-image",
                            title="Image by Kevin Dinkel", alt='Learn Dash Bootstrap Card Component',
                            style={"height": "25rem"}),
                dbc.CardBody(
                    [
                        html.H5(id='name-image', className="card-title"),
                        dbc.Progress(id='progress', color="success")
                    ]
                )],
            outline=False,
            style={"height": "30rem"}
        ),
        dbc.Card(
            dbc.CardBody(
                [
                    html.H4("Click on the diagnosis buttons below to label the show image and display the next one:",
                            className="card-title"),
def display_movies_to_rate(movieID_toRate_list):
    cards = []
    for ID in movieID_toRate_list:
        movieCard = dbc.Card(
            [
                dbc.CardImg(src=movies.loc[movies['MovieID'] == ID,
                                           'image_url'],
                            top=True),
                dbc.CardBody(
                    html.P(movies.loc[movies['MovieID'] == ID, 'Title'],
                           className="card-text")),
                dcc.Slider(
                    id={
                        'type': 'rating_value',
                        'index': ID
                    },
                    min=1,
                    max=5,
                    step=1,
                    marks={
                        1: {
                            'label': '1',
                            'style': {
                                'color': '#F5ECCE'
                            }
                        },
                        2: {
                            'label': '2',
                            'style': {
                                'color': '#F5ECCE'
                            }
                        },
                        3: {
                            'label': '3',
                            'style': {
                                'color': '#F5ECCE'
                            }
                        },
                        4: {
                            'label': '4',
                            'style': {
                                'color': '#F5ECCE'
                            }
                        },
                        5: {
                            'label': '5',
                            'style': {
                                'color': '#F5ECCE'
                            }
                        },
                    },
                ),
            ],
            color='info',
            inverse=True,
            style={'width': '22rem'},
        )
        cards.append(movieCard)
    rows = []
    cols = []
    for index in range(len(movieID_toRate_list)):
        if ((index) % 4 == 3):
            cols.append(dbc.Col(cards[index]))
            rows.append(dbc.Row(cols, align="start"))
            cols = []
        else:
            cols.append(dbc.Col(cards[index]))

    cardsDIV = cardsDIV = html.Div(style={
        'height': '650px',
        'overflow-y': 'auto',
        'overflow-x': 'hidden'
    },
                                   children=rows)
    return cardsDIV
Exemple #4
0
    "https://raw.githubusercontent.com/Coding-with-Adam/Dash-by-Plotly/master/Analytic_Web_Apps/Linkedin_Analysis/messages.csv"
)
df_msg["DATE"] = pd.to_datetime(df_msg["DATE"])

# Bootstrap themes by Ann: https://hellodash.pythonanywhere.com/theme_explorer
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.LUX])

app.layout = dbc.Container(
    [
        dbc.Row(
            [
                dbc.Col(
                    [
                        dbc.Card(
                            [
                                dbc.CardImg(src='/assets/linkedin-logo2.png'
                                            )  # 150px by 45px
                            ],
                            className='mb-2'),
                        dbc.Card([
                            dbc.CardBody([
                                dbc.CardLink(
                                    "Charming Data",
                                    target="_blank",
                                    href="https://youtube.com/charmingdata")
                            ])
                        ]),
                    ],
                    width=2),
                dbc.Col([
                    dbc.Card([
                        dbc.CardBody([
Exemple #5
0
                       labelClassName='mr-3 text-success font-weight-bold'
                       )  #change spacing, text color

# Graphs
graph1 = dcc.Graph(id='graph1')
graph2 = dcc.Graph(id='graph2')
graph3 = dcc.Graph(id='graph3')

# Card
card1 = dbc.Card(
    [
        dbc.CardBody(
            html.P("We're better together. Help each other out!",
                   className="card-text")),
        dbc.CardImg(
            src="https://media.giphy.com/media/Ll0jnPa6IS8eI/giphy.gif",
            bottom=True),
    ],
    style={"width": "24rem"},
)

card2 = dbc.Card(
    [
        dbc.CardImg(
            src='https://media.giphy.com/media/Ll0jnPa6IS8eI/giphy.gif',
            top=True,
            bottom=False,
            title='Image title and stuff',
            alt='Learn Dash bootstrap card'),
        dbc.CardBody([
            html.H4('learn dash with charming data', className='card-title'),
    MODEL_PATH.joinpath('Final random forest-heroku_version.pkl'))
#rf_model = load_model(MODEL_PATH.joinpath('\models\Final random forest Model'))
if rf_model:
    print('rf_model loaded')
# app = dash.Dash(__name__, external_stylesheets=[dbc.themes.DARKLY])

# app = dash.Dash(__name__) this will read from /assets

approval_str = ['opppps...something is missing from the info-happy hoiday!']
print(approval_str)
########################## 1st card#########################
card_dropdown = dbc.Card(
    [
        dbc.CardImg(src='/assets/LC-Logo.png',
                    top=True,
                    bottom=False,
                    title="LC-Logo",
                    alt='Learn Dash Bootstrap Card Component'),
        dbc.CardBody([
            html.H4([
                "Predict Your Loan Approval Rate",
                dbc.Badge(
                    'Powered by Random Forest and Logistic Regression',
                    className='ml-1',
                    color='success',
                    pill=True,
                    href=
                    'https://arxiv.org/ftp/arxiv/papers/0804/0804.0650.pdf',
                    id='rf-lr-badge')
            ]),
            # className="card-title"),
Exemple #7
0
            dcc.Markdown(
                '''Created by [Angus Sinclair](https://github.com/arms3)
Icons made by [Freepik](https://www.freepik.com/) from [www.flaticon.com](https://www.flaticon.com/) is licensed by
[CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/)'''),
        ],
                 className='col-lg-12'),
    ],
             className='row'),
],
                     id='footer')

# Contact card layout
contact_card = dbc.Card([
    dbc.CardHeader(html.H3("Contact Details", style={'margin': 0})),
    dbc.Row([
        dbc.Col(dbc.CardImg(src=app.get_asset_url('mug.png'),
                            style={'max-width': '120px'}),
                width=3),
        dbc.Col([
            dbc.Row([
                'email: ',
                dbc.CardLink('*****@*****.**',
                             href='mailto:[email protected]')
            ]),
            dbc.Row([
                'git: ',
                dbc.CardLink('github.com/arms3/whiskyInvest',
                             href='https://github.com/arms3/whiskyInvest')
            ]),
            dbc.Row([
                'app: ',
                dbc.CardLink('whisky-invest.herokuapp.com',
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html

from elements import (color, color2)

content = dbc.Row(
    dbc.Col([
        dcc.Markdown('''
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 
culpa qui officia deserunt mollit anim id est laborum."
'''),
        html.Br(),
        dbc.Card(dbc.CardImg(src='https://picsum.photos/500/300')),
        html.Br(),
        dcc.Markdown('''
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 
culpa qui officia deserunt mollit anim id est laborum."
'''),
        html.Br()
    ]))
Exemple #9
0
url_profit ="https://assets4.lottiefiles.com/private_files/lf30_qKbFdb.json"

url_logo ="https://assets8.lottiefiles.com/private_files/lf30_kanwuonz.json"

options = dict(loop =True,autoplay = True,rendererSettings=dict(preservesAspectRatio='xMidYMid slice'))

app = Dash(__name__,external_stylesheets=[dbc.themes.SOLAR])
server = app.server

app.layout= dbc.Container([
#row 1
    dbc.Row([
        dbc.Col([
            dbc.Card([
                dbc.CardImg(src='https://www.sabertoothtech.in/static/images/SabertoothLogo.png')
            ],className='mb-2'),

        ], width=2),
        dbc.Col([
            dbc.Card([
                dbc.CardBody([
                    dcc.DatePickerSingle(
                        id='my-date-picker-start',
                        date=datetime.date(2018,1,1),
                        className='ml-5'
                    ),
    dcc.DatePickerSingle(
                        id='my-date-picker-end',
                        date=datetime.date.today(),
                        className='mb-2 ml-2'
df_cnt['month'] = df_cnt['month'].apply(lambda x: calendar.month_abbr[x])

df_invite = pd.read_csv("C:/Users/Yousef Hanna/Desktop/Data/Invitations.csv")
df_invite["Sent At"] = pd.to_datetime(df_invite["Sent At"])

df_msg = pd.read_csv("C:/Users/Yousef Hanna/Desktop/Data/messages.csv")
df_msg["DATE"] = pd.to_datetime(df_msg["DATE"])

# Bootstrap themes by Ann: https://hellodash.pythonanywhere.com/theme_explorer
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.LUX])

app.layout = dbc.Container([
    dbc.Row([
        dbc.Col([
            dbc.Card([
                dbc.CardImg(
                    src='C:/Users/Yousef Hanna/Desktop/Data/linkdin.png')
            ],
                     className='mb-2'),
            dbc.Card([
                dbc.CardBody([
                    dbc.CardLink(
                        "My Account",
                        target="_blank",
                        href="https://www.linkedin.com/in/yousef-osama/")
                ])
            ]),
        ],
                width=2),
        dbc.Col([
            dbc.Card([
                dbc.CardBody([
Exemple #11
0
                    'content':
                    'width = device-width, initial-scaled=1.0'
                }])

#App Layout
app.layout = html.Div([
    html.Br(),
    html.H1("Financial Dashboard", style={'text-align': 'center'}),
    html.Br(),
    dbc.Container([
        dbc.Row([
            dbc.Col([
                dbc.Card([
                    dbc.CardImg(
                        src="JNJ.png",
                        top=True,
                        style={"width": "10px"},
                    ),
                ])
            ])
        ])
    ])
])

#The callback
# @app.callback([])

# def update_graph():
#     pass

#Launch App
Exemple #12
0
def render_content(headline="None",
                   image_url="localhost:8000/404.png",
                   publication="",
                   description="",
                   content="",
                   audience_filters=['local']):
    content = html.Div(
        children=daq.DarkThemeProvider(
            theme=theme,
            children=html.Div([
                dcc.Interval(id="tick"),
                html.Div([
                    # dbc.Row(
                    #     [
                    #         dbc.Col(
                    dbc.Form([
                        dbc.Container([
                            dbc.Row([
                                dbc.Col(
                                    dbc.Label("Categories:", ),
                                    width=1,
                                ),
                                dbc.Col(
                                    dcc.Dropdown(
                                        options=[
                                            {
                                                "label": "local",
                                                "value": "local",
                                            },
                                            {
                                                "label": "regional",
                                                "value": "regional",
                                            },
                                            {
                                                "label": "state",
                                                "value": "state",
                                            },
                                            {
                                                "label": "national",
                                                "value": "national",
                                            },
                                            {
                                                "label": "international",
                                                "value": "international",
                                            },
                                            {
                                                "label": "unbound",
                                                "value": "unbound",
                                            },
                                        ],
                                        id='audience-filters',
                                        value=audience_filters,
                                        multi=True,
                                    ),
                                    width=4,
                                    className="mw-25",
                                    # style={"min-width": "25vw"}
                                ),
                                # className="w-100",
                                #     inline=True,
                                #     className='mr-4',
                                # dbc.FormGroup(
                                #     [
                                dbc.Col(dbc.Label("Order by"), width=1),
                                dbc.Col(
                                    dcc.Dropdown(options=[
                                        {
                                            "label": "gradient descent",
                                            "value": "gradient descent",
                                        },
                                        {
                                            "label": "ambiguity",
                                            "value": "ambiguity",
                                        },
                                    ],
                                                 id='sort-order'),
                                    width=4,
                                ),
                            ])
                        ])
                    ]),
                    html.Br(),
                    # className="w-100",
                    # inline=True
                    #         ),
                    #     ),
                    # ]
                    #     ),
                    # ]), ]),
                    # dbc.Row(
                    #     [
                    #
                    #         dbc.Col(
                    #             dbc.Card([dbc.CardImg(src=image_url)], style={'max-height': '38vh'}), width=12,
                    #
                    #         ),
                    #         # dbc.Col(width=4),
                    #
                    #     ],
                    #     align='center',
                    #
                    # ),
                    dbc.Row(
                        [
                            dbc.Col(
                                dbc.Jumbotron(
                                    [
                                        html.H6(publication,
                                                className='text-muted',
                                                style={
                                                    "font-variant":
                                                    'small-caps'
                                                }),
                                        html.H1(
                                            html.B(headline),
                                            className="display-3",
                                            id="headline",
                                        ),
                                        html.P(
                                            description,
                                            className="lead",
                                        ),
                                        # html.Hr(className="my-2"),
                                        dbc.Card(
                                            [dbc.CardImg(src=image_url)],
                                            style={
                                                "margin":
                                                "1.5vh 3.37vh 1.5vh 0.57vh"
                                            }),
                                        *[
                                            html.
                                            P(f"""{line1} {line2 if line2 else ""}""",
                                              className='article-content')
                                            for line1, line2 in grouper(
                                                nlp(content).sents, 2)
                                        ],
                                    ],
                                    style={"padding": "20px"},
                                ),
                                width=11)
                        ],
                        style={'margin-top': '5vh'}),
                    dbc.Row([dbc.Col(dbc.ListGroup([], id="suggestions"))]),
                ]),
            ]),
        ),
        style=CONTENT_STYLE,
    )
    return content
Exemple #13
0
            "background-size": "cover",
            "height": "700px",
            "color": "rgb(0,0,0)",
            "text-align": "center"},
 ),
 html.Br(className="my-2"),
 dbc.Row([
     html.H3("About the Development Team"),
 ]),
 html.Br(className="my-2"),
 dbc.Row([
     dbc.CardDeck(
         [
             dbc.Card(
                 [
                     dbc.CardImg(src="/assets/marc.jpeg", top=True, style={"border-radius": "130px"}),
                     dbc.CardBody(
                         [
                             html.H5("Marc-Robin Gruener", className="card-title"),
                             html.P([
                                 "Marc's main responsibility was turning the various Machine Learning models into a comprehensive software solution. He developed the backend including the database queries and data manipulations that transformed the data into a standardized format, improving the efficiency. Furthermore, he defined and impelemted various features in the app such as the heatmap functionality. He also designed and created the frontend of the app. Please contact Marc  regarding questions about the backend and the features: ",
                                 html.A('email',
                                        href='mailto:[email protected]?subject=IBM Temperature Management Dashboard',
                                        target='_blank'), ],
                                 className="card-text",
                                 style={"text-align": "justify", "font-size": "75%"},
                             ),
                             html.Div(
                                 dbc.Button(
                                     "LinkedIn", href='https://www.linkedin.com/in/marc-robin-gruener/',
                                     target="_blank", color="primary", className="mt-auto"
Exemple #14
0
def modal(id_suffix: str = "",
          is_open: bool = True,
          header: str = "",
          body: str = ""):
    """
    Creat a modal used in every view to guide the user.
    Parameters
    ----------
    id_suffix: `str`
        Suffix used to make ids unique
    is_open: `bool`
        Control the visibility of the modal
    header: `str`
        Text for the header of the modal
    body: `str`
        Text for the body fo the modal
    Returns
    -------
    The dash component
    """
    id_modal = f"modal_{id_suffix}"
    id_close_btn = f"close_{id_suffix}"
    id_dont_show_again = f"dont_show_again_{id_suffix}"
    id_dont_show_again_div = f"dont_show_again_div_{id_suffix}"
    id_close_area = f"close_area_{id_suffix}"
    id_image = f"modal_image_{id_suffix}"

    return html.Div([
        dbc.Modal(
            [
                dbc.ModalHeader(header),
                dbc.ModalBody(children=[
                    body,
                    html.Div(
                        id=id_close_area,
                        children=[
                            html.Div(
                                id=id_dont_show_again_div,
                                children=[
                                    dbc.Checkbox(
                                        id=id_dont_show_again,
                                        className="mt-4",
                                    ),
                                    dbc.Label(
                                        "Do not show again",
                                        html_for=id_dont_show_again,
                                        className="mr-1 mt-3 ml-1 pt-1",
                                    ),
                                ],
                            ),
                            dbc.Button(
                                "Close",
                                id=id_close_btn,
                                color="primary",
                                className="p-2 m-2",
                            ),
                        ],
                        className="d-flex justify-content-end bg-light",
                    ),
                    dbc.Card(dbc.CardImg(id=id_image)),
                ]),
                dbc.ModalFooter(children=[]),
            ],
            id=id_modal,
            is_open=is_open,
            size="xl",
        ),
    ])
Exemple #15
0
        dbc.Col(children=dbc.Card([
            dbc.CardBody([
                dbc.CardTitle("This card has a title"),
                dbc.CardText("and some text, and a footer!"),
            ]),
            dbc.CardFooter("Footer"),
        ],
                                  outline=False,
                                  color="primary")),
        dbc.Col(children=dbc.Card([
            dbc.CardBody([
                dbc.CardTitle("Card title"),
                dbc.CardSubtitle("Card subtitle")
            ]),
            dbc.CardImg(
                src=
                "https://placeholdit.imgix.net/~text?txtsize=33&txt=318%C3%97180&w=318&h=180"
            ),
            dbc.CardBody([
                dbc.CardText(
                    "Some quick example text to build on the card title and make up the bulk of the card's content."
                ),
                dbc.CardLink("A link", href="#"),
                dbc.CardLink("Another link", href="#"),
            ]),
        ])),
    ],
            className="mt-2"),

    # 画图类 ========================================================================================
    dcc.Graph(id="example-graph",
              figure={
Exemple #16
0
def calculate_suggestions(vrb1, id_photo, less):
    #id = iris.search(vrb1)[0]
    row = iris.meta.loc[id_photo]
    res = round(row[vrb1], 1)
    product = iris.meta.loc[id_photo, "product_name"]
    brand = iris.meta.loc[id_photo, "brands"]
    category = iris.meta.loc[id_photo, "categories_en"]
    catlist = category.split(",")

    i = 0
    n = random.randrange(1, 26712)
    objects = []
    no_results = 0
    # csv_path="processed.csv.gz"
    # df = pd.read_csv(csv_path)
    # df = df[(df["product_name"] == product) & (df["brand"] ==brand)]
    # print(df)

    while True:
        if math.isnan(res):
            objects.append(
                html.Div([
                    html.
                    H3("!  The value is empty. Please select other suggestion criteria"
                       )
                ],
                         style={"color": '#FF0000'}))
            break
        row_test = iris.meta.loc[n]
        res_test = round(row_test[vrb1], 1)
        category_test = iris.meta.loc[n, "categories_en"]
        catlist_test = category_test.split(",")
        common = list(set(catlist) & set(catlist_test))

        if res_test is not None:
            if less:
                kk = res_test < res
            else:
                kk = res_test > res

            if (kk and common != []):
                newone = dbc.Card(
                    [
                        dbc.CardImg(src=row_test["image_url"],
                                    style={'height': '200px'},
                                    top=True),
                        dbc.CardBody([
                            html.H4(str(iris.meta.loc[n, "brands"]) + ' - ' +
                                    str(iris.meta.loc[n, "product_name"]),
                                    className="card-title"),
                            html.P(
                                [
                                    "Calories:" + str(
                                        round(
                                            iris.meta.loc[n,
                                                          "energy-kcal_100g"],
                                            1)),
                                    html.Br(), "Proteins:" + str(
                                        round(
                                            iris.meta.loc[n, 'proteins_100g'],
                                            1)) + "g",
                                    html.Br(), "Carbs: " + str(
                                        round(
                                            iris.meta.loc[
                                                n, "carbohydrates_100g"], 1)) +
                                    "g",
                                    html.Br(), "Fat: " +
                                    str(round(iris.meta.loc[n, "fat_100g"],
                                              1)) + "g",
                                    html.Br(), "Sugar: " + str(
                                        round(iris.meta.loc[n, "sugars_100g"],
                                              1)) + "g",
                                    html.Br(), "Salt: " +
                                    str(round(iris.meta.loc[n, "salt_100g"],
                                              3)) + "g",
                                    html.Br(),
                                    html.Hr(),
                                    dcc.Markdown('''**Keywords: **'''),
                                    str(common)[1:-1]
                                ],
                                className="card-text",
                            ),
                            #dbc.Button("Go somewhere", color="primary"),
                        ]),
                    ],
                    style={
                        "width": "200px",
                        'display': 'inline-block',
                        'margin-left': '20px',
                        'margin-top': '20px',
                        'verticalAlign': 'top'
                    },
                )
                #objects.append(html.Div([html.Img(src=row_test["image_url"], height='250px'),
                #html.H5(common)]))
                objects.append(newone)
                #objects.append(n)
                i = i + 1

        n = n + 10
        if i == 10:
            break
        if n >= 26712:
            no_results += 1
            n = 1
        if no_results == 2:
            objects.append(
                html.Div([
                    html.
                    H3("!  No products were found matching this category. Please select another product."
                       )
                ],
                         style={"color": '#FF0000'}))
            break
    return objects
Exemple #17
0
    ]),
]

card_content_2 = dbc.CardBody([
    html.Blockquote(
        [
            html.P("A learning experience is one of those things that says, "
                   "'You know that thing you just did? Don't do that.'"),
            html.Footer(html.Small("Douglas Adams", className="text-muted")),
        ],
        className="blockquote",
    )
])

card_content_3 = [
    dbc.CardImg(src="/static/images/placeholder286x180.png", top=True),
    dbc.CardBody([
        html.H5("Card with image", className="card-title"),
        html.P(
            "This card has an image on top, and a button below",
            className="card-text",
        ),
        dbc.Button("Click me!", color="primary"),
    ]),
]

cards = dbc.CardColumns([
    dbc.Card(card_content_1, color="primary", inverse=True),
    dbc.Card(card_content_2, body=True),
    dbc.Card(card_content_1, color="secondary", inverse=True),
    dbc.Card(card_content_3, color="info", inverse=True),
Exemple #18
0
def add_dash(server, login_reg=True):

    external_stylesheets = [
        dbc.themes.BOOTSTRAP,
    ]

    app = dash.Dash(
        server=server,
        url_base_pathname=URL_BASE,
        suppress_callback_exceptions=True,
        external_stylesheets=external_stylesheets
    )

    app.layout = dbc.Container([
        html.H1('Add / Modify User Image Database'),
        html.H3('Select Row to Edit Existing'),
        dbc.Button('Refresh List', id=f'{APP_ID}_database_refresh_button'),
        dash_table.DataTable(
            id=f'{APP_ID}_database_dt',
            columns=[
                {'name': c, "id": c, 'type': 'text'} for c in ['name', 'creator', 'id', 'img_web_url']
            ],
            data=[{}],
            editable=False,
            row_deletable=False,
            row_selectable='single',
            page_action='none',
            style_table={'maxHeight': '400px', 'overflowY': 'auto'},
            css=[{'selector': '.row', 'rule': 'margin: 0'}]
        ),
        html.Br(),
        html.H3("Upload to Add New Image"),
        dcc.Upload(
            id=f'{APP_ID}_upload',
            children=[
                dbc.Button('Drag and Drop or click to browse')
            ]
        ),
        dbc.Row([
            dbc.Col(
                dbc.FormGroup([
                    dbc.Label('Image Name'),
                    dbc.Input(id=f'{APP_ID}_name_input'),
                ]),
            ),
            dbc.Col(
                dbc.FormGroup([
                    dbc.Label('Creator Name'),
                    dbc.Input(id=f'{APP_ID}_creator_input'),
                ]),
            )
        ]),
        dbc.FormGroup([
            dbc.Label('Web URL'),
            dbc.Input(id=f'{APP_ID}_web_url_input'),
        ]),
        dbc.Card([
            dbc.CardImg(id=f'{APP_ID}_card_Img', src='', top=True, style={'width': '18rem'}),
            dbc.CardBody([
                html.H4('', id=f'{APP_ID}_card_name_H4'),
                html.P('', id=f'{APP_ID}_card_creator_P'),
                dbc.ButtonGroup([
                    dbc.Button('Enlarge', id=f'{APP_ID}_card_enlarge_button', color='secondary'),
                    dbc.Button('Submit to Database', id=f'{APP_ID}_card_submit_button', color='primary', disabled=True),
                ]),
                dbc.CardFooter(
                    dbc.CardLink('Web Link', id=f'{APP_ID}_card_web_link', href='', external_link=True, target="_blank")
                )

            ])
        ],
            style={'max-width': '18rem'}
        ),
        html.Div(id=f'{APP_ID}_upload_feedback_div'),

    ])

    @app.callback(
        Output(f'{APP_ID}_card_Img', 'src'),
        [
            Input(f'{APP_ID}_upload', 'contents'),
            Input(f'{APP_ID}_database_dt', "derived_virtual_selected_rows"),
        ],
        [State(f'{APP_ID}_database_dt', "data")]
    )
    def user_image_upload_img(contents, derived_virtual_selected_rows, data):
        ctx = dash.callback_context
        if not ctx.triggered:
            raise PreventUpdate

        if ctx.triggered[0]['prop_id'].split('.')[0] == f'{APP_ID}_upload' and contents is not None:
            im_file2 = make_thumb(contents)
            im_b64 = b64encode(im_file2.read()).decode('utf-8')
            return f'data:image/jpg;base64, {im_b64}'

        elif ctx.triggered[0]['prop_id'].split('.')[0] == f'{APP_ID}_database_dt':
            if derived_virtual_selected_rows is not None and len(derived_virtual_selected_rows) > 0:
                ui_id = data[derived_virtual_selected_rows[0]]['id']
                uimg = User_Image.query.filter_by(id=ui_id).first()
                return f"data:image/jpg;base64, {b64encode(uimg.thumb).decode('utf-8')}"
        else:
            return None


    @app.callback(
        Output(f'{APP_ID}_card_name_H4', 'children'),
        [
            Input(f'{APP_ID}_name_input', 'value')
        ]
    )
    def user_image_upload_name(name):
        return name


    @app.callback(
        Output(f'{APP_ID}_card_creator_P', 'children'),
        [
            Input(f'{APP_ID}_creator_input', 'value')
        ]
    )
    def user_image_upload_creator(creator):
        return creator


    @app.callback(
        Output(f'{APP_ID}_card_web_link', 'href'),
        [
            Input(f'{APP_ID}_web_url_input', 'value')
        ]
    )
    def user_image_upload_web_url(web_link):
        return web_link


    @app.callback(
        Output(f'{APP_ID}_card_submit_button', 'disabled'),
        [
            Input(f'{APP_ID}_name_input', 'value'),
            Input(f'{APP_ID}_creator_input', 'value'),
            Input(f'{APP_ID}_web_url_input', 'value'),
            Input(f'{APP_ID}_upload', 'contents'),
            Input(f'{APP_ID}_database_dt', "derived_virtual_selected_rows"),
            Input(f'{APP_ID}_card_Img', 'src')
        ],
    )
    def user_image_upload_submit_enable(name, creator, web_url, contents, derived_virtual_selected_rows, img_src):
        if any([v is None or v == '' for v in [name, creator, web_url, img_src]]):
            return True
        else:
            return False


    @app.callback(
        Output(f'{APP_ID}_upload_feedback_div', 'children'),
        [
            Input(f'{APP_ID}_card_submit_button', 'n_clicks'),
            Input(f'{APP_ID}_name_input', 'value'),
            Input(f'{APP_ID}_creator_input', 'value'),
            Input(f'{APP_ID}_web_url_input', 'value'),
            Input(f'{APP_ID}_card_Img', 'src')
        ],
        [
            State(f'{APP_ID}_upload', 'contents'),
            State(f'{APP_ID}_upload', 'filename'),
            State(f'{APP_ID}_database_dt', "derived_virtual_selected_rows"),
            State(f'{APP_ID}_database_dt', "data")
        ]
    )
    def user_image_upload_save(n_clicks, name, creator, web_url, img_src, contents, filename, derived_virtual_selected_rows, data):
        ctx = dash.callback_context
        if not ctx.triggered:
            raise PreventUpdate

        if ctx.triggered[0]['prop_id'].split('.')[0] in [f'{APP_ID}_name_input', f'{APP_ID}_creator_input', f'{APP_ID}_web_url_input', f'{APP_ID}_card_Img']:
            if any([v is None or v == '' for v in [name, creator, web_url, img_src]]):
                return dbc.Alert([html.H3('Incomplete'), html.P('fill all forms and load image before submitting')], color='danger')
            else:
                return dbc.Alert([html.H3('Ready to Submit'), html.P('going once...')], color='primary')
        else:
            im_filename = ''
            try:
                # if selected remove existing before submitting
                if len(derived_virtual_selected_rows) > 0:
                    ui_id = data[derived_virtual_selected_rows[0]]['id']
                    uimg = User_Image.query.filter_by(id=ui_id).first()
                    uimg.name = name
                    uimg.creator = creator
                    uimg.img_web_url = web_url
                    db.session.commit()
                    db.session.close()
                else:
                    img_file = make_img_file(contents)
                    im_filename = uuid.uuid4().hex + '.' + filename.split('.')[-1]
                    with open(os.path.join(server.config['IMG_FILE_DIR'], secure_filename(im_filename)), 'wb') as f:
                        f.write(img_file.getbuffer())

                    thumb_file = make_thumb(contents)
                    user_img = User_Image(
                        name=name,
                        creator=creator,
                        img_web_url=web_url,
                        img_dir_url=secure_filename(im_filename),
                        thumb=thumb_file.read()
                    )
                    db.session.add(user_img)
                    db.session.commit()
                    db.session.close()
            except Exception as e:
                pf = Path(server.config['IMG_FILE_DIR']) / secure_filename(im_filename)
                if pf.is_file():
                    pf.unlink()
                return dbc.Alert([html.H3('Add Failed!'), str(e)], color='danger')

            return dbc.Alert([html.H3('File Added to Database!'), html.P('claps and cheers all around!')], color='success')


    @app.callback(
        [
            Output(f'{APP_ID}_name_input', 'value'),
            Output(f'{APP_ID}_creator_input', 'value'),
            Output(f'{APP_ID}_web_url_input', 'value'),
        ],
        [Input(f'{APP_ID}_database_dt', "derived_virtual_selected_rows")],
        [State(f'{APP_ID}_database_dt', "data")]
    )
    def user_image_edit_select(derived_virtual_selected_rows, data):
        if derived_virtual_selected_rows is None or len(derived_virtual_selected_rows) == 0:
            raise PreventUpdate
        name = data[derived_virtual_selected_rows[0]]['name']
        creator = data[derived_virtual_selected_rows[0]]['creator']
        img_web_url = data[derived_virtual_selected_rows[0]]['img_web_url']
        return [name, creator, img_web_url]


    @app.callback(
        [
            Output(f'{APP_ID}_database_dt', 'data'),
            Output(f'{APP_ID}_database_dt', 'selected_rows'),
         ],
        [
            Input(f'{APP_ID}_database_refresh_button', 'n_clicks')
        ]
    )
    def user_image_edit_refresh(n_clicks):
        user_imgs = db.session.query(User_Image).all()
        data = []
        for ui in user_imgs:
            data.append({'name': ui.name, 'creator': ui.creator, 'id': ui.id, 'img_web_url': ui.img_web_url})
        return data, []


    if login_reg:
        _protect_dashviews(app)

    return server
Exemple #19
0
bottomwear_placeholder_men = process_image(
    Path("images", "Bottomwear", "PlaceHolderMen.png"),
)

shoes_placeholder_men = process_image(
    Path("images", "Shoes", "PlaceHolderMen.png"),
)

# --------------------------------------- CARDS ----------------------------------------
headwear = (
    dbc.Card(
        [
            dbc.CardImg(
                src=headwear_placeholder_men,
                id="card_img_headwear",
                top=True,
            ),
        ]
    ),
)


topwear = (
    dbc.Card(
        [
            dbc.CardImg(
                src=topwear_placeholder_men,
                top=True,
            ),
        ]
dff = dff[dff.indicator.isin(['high'])]

app = dash.Dash(__name__,
                external_stylesheets=[dbc.themes.BOOTSTRAP],
                meta_tags=[{
                    'name': 'viewport',
                    'content': 'width=device-width, initial-scale=1.0'
                }])

app.layout = dbc.Container([
    dbc.Row([
        dbc.Col([
            dbc.Card([
                dbc.CardImg(
                    src="/assets/tata.png",
                    top=True,
                    style={"width": "6rem"},
                ),
                dbc.CardBody([
                    dbc.Row([
                        dbc.Col([html.P("CHANGE (1D)")]),
                        dbc.Col([
                            dcc.Graph(id='indicator-graph',
                                      figure={},
                                      config={'displayModeBar': False})
                        ])
                    ]),
                    dbc.Row([
                        dbc.Col([
                            dcc.Graph(id='daily-line',
                                      figure={},
Exemple #21
0
def get_art_con(title, popularity=-1, similarity=-1):
    '''
    Create article within dash_bootstrap_components card html object.
    For now we're using random example images to draw the article preview.
    
    INPUT:
        title - (str) article title
        popularity - (int or float) single value that represents popularity of an article
        similarity - (int or float) single value that represents similiarity of an article
        
    OUTPUT:
        card - (object) dash_bootstrap_components HTML object
    '''

    if (popularity != -1) and (similarity != -1):
        badge_list = [
            dbc.Badge("Popularity: " + str(popularity),
                      color="light",
                      className="mr-1"),
            dbc.Badge("Similarity: " + str(similarity),
                      color="light",
                      className="mr-1")
        ]
    elif (similarity != -1):
        badge_list = [
            dbc.Badge("Similarity: " + str(similarity),
                      color="light",
                      className="mr-1")
        ]
    elif (popularity != -1):
        badge_list = [
            dbc.Badge("Popularity: " + str(popularity),
                      color="light",
                      className="mr-1")
        ]
    else:
        badge_list = [
            dbc.Badge("Similarity: " + str(similarity),
                      color="light",
                      className="mr-1 invisible")
        ]

    card = dbc.Card([
        dbc.CardImg(src=random.choice(example_images), top=True),
        dbc.CardBody([
            html.P(
                title,
                className="card-text",
            ),
            dbc.Col(children=[
                dbc.Row(children=badge_list, style={"margin-bottom": 5}),
                dbc.Row(
                    dbc.Button("Read Article (dummy)",
                               color="info",
                               size="sm",
                               style={"font-size": "0.8em"}))
            ])
        ])
    ],
                    style={"height": "290px"})

    return card
Exemple #22
0
             html.P(
                 [
                     "This card uses the ",
                     html.Code("w-50"),
                     " class to set the width to 50%",
                 ],
                 className="card-text",
             ),
         ]),
         className="w-50",
     ),
 ]),
 html.Br(),
 dbc.Row([
     dbc.Col(dbc.Card([
         dbc.CardImg(src="./assets/placeholder286x180.png", top=True),
         dbc.CardBody([
             html.H5("Card title", className="card-title"),
             html.P("This card has some text content, but not much else"),
             dbc.Button("Go somewhere", color="primary"),
         ]),
     ], ),
             width='4'),
     dbc.Col(dbc.Card([
         dbc.CardBody([
             html.H5("Card title", className="card-title"),
             html.
             P("This card also has some text content and not much else, but "
               "it is twice as wide as the first card."),
             dbc.Button("Go somewhere", color="primary"),
         ]),
Exemple #23
0
# https://medium.com/swlh/dashboards-in-python-for-beginners-using-dash-responsive-mobile-dashboards-with-bootstrap-css-2a0d05a53cf6

import dash
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html

app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

card = dbc.Card(
    [
        dbc.CardImg(src="https://images.theconversation.com/files/319652/original/file-20200310-61148-vllmgm.jpg?ixlib=rb-1.1.0&q=45&auto=format&w=754&fit=clip", top=True),
        dbc.CardBody(
            [
                html.H4("Card title", className="card-title"),
                html.P(
                    "Some quick example text to build on the card title and "
                    "make up the bulk of the card's content.",
                    className="card-text",
                ),
                dbc.Button("Go somewhere", color="primary"),
            ]
        ),
    ],
    style={"width": "18rem"},
)

# ==============================
myAlert = dbc.Alert("One of two columns", color="primary")
myHead = html.H1("Cyberport Bus ETA", style={'textAlign': 'center'})
myLayout = [
Exemple #24
0
          inplace=True)

ciq = df.query("s_type == 'cities'").loc[:, ["Score", "Short Description"]]
coq = df.query("s_type == 'corporates'").loc[:, ["Score", "Short Description"]]

# ------------------------------------------------------------------------------
# create page content

cards_team = dbc.CardDeck(
    [
        dbc.Card([
            dbc.CardHeader("David Slabon"),
            dbc.CardImg(
                src="/assets/picture_david.jpeg",
                top=True,
                bottom=False,
                title="David Slabon",
                alt='Loading Error',
            ),
            dbc.CardBody([
                dbc.Row([
                    dbc.Button("GitHub",
                               href='https://github.com/davidslabon',
                               color="primary",
                               className="mr-1",
                               size="lg",
                               style={
                                   "font-size": "larger",
                                   "text-decoration": "none"
                               }),
                    dbc.Button("LinkedIn",
Exemple #25
0
figura2 = px.line(edad_egresos_fallecidos,
                  x="Edad",
                  y="Identificacion",
                  color="Egreso")

sexo_egresos = pd.DataFrame(
    casos_positivos.groupby(['Sexo', 'Egreso'
                             ])['Identificacion'].count()).reset_index()
sexo_egresos = pd.DataFrame(
    casos_positivos.groupby(['Sexo', 'Egreso'
                             ])['Identificacion'].count()).reset_index()
figura3 = px.bar(sexo_egresos, x='Sexo', y="Identificacion", color='Egreso')

card = dbc.Card(
    [
        dbc.CardImg(src="assets/images/map.png", top=True),
        dbc.CardBody([
            html.H4("Geo espacial", className="card-title"),
            html.P(
                "Informacion geo espacial de casos de Covid19 en Bucaramanga",
                className="card-text",
            ),
            dbc.Button("Go somewhere", color="primary"),
        ]),
    ],
    style={"width": "18rem"},
)

work_equipe = dbc.CardGroup([
    dbc.Card(
        [
Exemple #26
0
import dash_bootstrap_components as dbc
import dash_html_components as html

card = dbc.Card(
    [
        dbc.CardImg(src="/assets/images/placeholder286x180.png", top=True),
        dbc.CardBody([
            html.H4("Card title", className="card-title"),
            html.P(
                "Some quick example text to build on the card title and "
                "make up the bulk of the card's content.",
                className="card-text",
            ),
            dbc.Button("Go somewhere", color="primary"),
        ]),
    ],
    style={"width": "18rem"},
)
Exemple #27
0
    "https://github.com/Kstyle0710/my_finance/raw/master/data2.csv")
dff = dff[dff.indicator.isin(['high'])]

app = dash.Dash(__name__,
                external_stylesheets=[dbc.themes.BOOTSTRAP],
                meta_tags=[{
                    'name': 'viewport',
                    'content': 'width=device-width, initial-scale=1.0'
                }])

app.layout = dbc.Container([
    dbc.Row([
        dbc.Col([
            dbc.Card([
                dbc.CardImg(src="/assets/tata.png",
                            top=True,
                            style={"width": "8rem"},
                            className="ml-3"),
                dbc.CardBody([
                    dbc.Row([
                        dbc.Col([html.P("CHANGE (1D)", className="ml-3")],
                                width={
                                    'size': 5,
                                    'offset': 1
                                }),
                        dbc.Col([
                            dcc.Graph(
                                id='indicator-graph',
                                figure={},
                                config={'displayModeBar': False},
                            )
                        ],
Exemple #28
0
def update_graph_interactive_image(value):

    print(value,'\n\n')
    value,label,stockLabel=int(value.split("$$$$$")[1]),value.split("$$$$$")[0],value.split("$$$$$")[2]


    if value==0:

        df=stock.getTrendingNews(stockLabel+" India")
        print(df)
        if len(df)==0:
            return [

                html.Div([
                
                html.Div(html.H5("Sorry! No trending news exist for this stock."))

                ],className="twelve columns", style={"margin-top":"1%","padding":"0.5%"})
                ]

        else:

            l=[]
            temp=[]

            for i in range(len(df)):
                
                imgUrl=df['Image'][i]
                url=df['URL'][i]
                ps=df['Title'][i]
                date=str(df['Date'][i]).split(" ")[0]
                card = dbc.Card(
        [
            dbc.CardImg(src=imgUrl, top=True),
            dbc.CardBody(
                [
                    html.H4(date, className="card-title"),
                    html.P( ps),
                    html.A(html.Button('Get News'),href=url)
                ]
            ),
        ],
        style={"width": "52%"},

    )
                temp.append(html.Div(card,className="six columns"))

                if i%2!=0 and i!=0:
                    l.append(html.Div(children=temp,className="row"))
                    l.append(html.Div())
                    temp=[]

                if (i%2==0 and i==len(df)-1):
                    l.append(card)
                    l.append(html.Div())
                  
                    
                    

            print(l)
       
            return [html.Div(html.H5(label),style={"padding":"2.6%","margin-top":"3.8%"}),html.Div(children=l,className="twelve columns offset-by-one",style={"padding":"5%"})]

                
        
    else:
      
        string=stock.getWordCloud(stockLabel+" India")
        if len(string)==0:
            return [
                html.Div([
                html.Div(html.H5("Sorry! No trending news exist for this stock to make the word cloud."))


                ],className="twelve columns", style={"margin-top":"1%","padding":"0.5%"})]

        else:
            img1=string[0]
            cards=dbc.Card(
    [
        dbc.CardBody(
            [html.H5("Word Cloud")]
        ),
        dbc.CardImg(
            src=(
                'data:image/jpg;base64,{}'.format(img1)
            )
        ),
         dbc.CardBody(
            [
                html.P(
                  "Word Cloud of Recent News of "+stockLabel
                ),
            ]
        ),
    ],
    style={"width": "69%"},
)
            print("success1")
            l=[]
            l.append(cards)
            return [html.Div(children=l,className="nine columns offset-by-three",style={"margin-top":"3%"})]
                width="auto"),
        ],
        color="dark",
        dark=True,
    ),
    dbc.Row(children=[
        dbc.Col(width=1),
        dbc.Col(children=[
            html.Br(),

            # title
            dbc.Row(
                dbc.Card(
                    [
                        dbc.CardImg(src="/assets/images/catan.jpg",
                                    top=True,
                                    id="img_exchange_this"),
                        dbc.CardBody([
                            html.H3(["Catan--"],
                                    className="card-title",
                                    id="wanted_exchange_this"),
                            html.H4(["CARCASSONNE"],
                                    className="card-title",
                                    id="offered_exchange_this"),
                            html.P(
                                "Almost new. No pieces are missing :)",
                                # "make up the bulk of the card's content.",
                                className="card-text",
                                id="description_exchange_this"),
                            html.Br(),
                            dbc.Button("Contact the exchanger",
Exemple #30
0
# create a new column iso_alpha in the df
# and fill it with appropriate iso 3 code
for k, v in d_country_code.items():
    kg_df.loc[(kg_df.Country == k), 'iso_alpha'] = v

###############################################################################
################ START OF APP #################################################
###############################################################################
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.MINTY])

app.layout = html.Div([
    dbc.Card([
        dbc.CardImg(
            src=
            "https://images.squarespace-cdn.com/content/v1/5919b0fd6b8f5b6a4a256b4e/1580488750529-30TFT9JN7P0XR5ZS4H8Y/ke17ZwdGBToddI8pDm48kH-KoR6KuuBcq9Z5xi422Q8UqsxRUqqbr1mOJYKfIPR7LoDQ9mXPOjoJoqy81S2I8N_N4V1vUb5AoIIIbLZhVYy7Mythp_T-mtop-vrsUOmeInPi9iDjx9w8K4ZfjXt2dsEF-sCd5QWO5hm7HfmdIziW4p77bAKWYf1JE4Sw1bIUW07ycm2Trb21kYhaLJjddA/1.31.20-Highlight.jpg",
            title="Image by Hearn Kirkwood",
            top=True,
            alt="Healthy Diet",
            style={}),
        dbc.CardBody([
            html.H1("COVID-19 and a Healthy Diet",
                    style={'textAlign': 'center'}),
            html.H3("Data exploration", style={'textAlign': 'center'}),
            html.H6([
                "Made with ",
                html.A('Dash',
                       href='https://dash.plotly.com/',
                       style={'color': '#000000'},
                       target='_blank)')
            ],
                    style={'textAlign': 'right'}),