Exemple #1
0
def test_dltx001_download_text(dash_dcc):
    text = "Hello, world!"
    filename = "hello.txt"
    # Create app.
    app = dash.Dash(__name__, prevent_initial_callbacks=True)
    app.layout = html.Div(
        [html.Button("Click", id="btn"),
         dcc.Download(id="download")])

    @app.callback(Output("download", "data"), Input("btn", "n_clicks"))
    def download(_):
        return dcc.send_string(text, filename)

    dash_dcc.start_server(app)

    # Check that there is nothing before clicking
    fp = os.path.join(dash_dcc.download_path, filename)
    assert not os.path.isfile(fp)

    dash_dcc.find_element("#btn").click()

    # Check that a file has been download, and that it's content matches the original text.
    until(lambda: os.path.exists(fp), 10)
    with open(fp, "r") as f:
        content = f.read()
    assert content == text
Exemple #2
0
def test_dlfi001_download_file(dash_dcc):
    filename = "Lenna.jpeg"
    asset_folder = os.path.join(os.path.dirname(__file__), "download-assets")
    # Create app.
    app = dash.Dash(__name__, prevent_initial_callbacks=True)
    app.layout = html.Div(
        [html.Button("Click", id="btn"),
         dcc.Download(id="download")])

    @app.callback(Output("download", "data"), Input("btn", "n_clicks"))
    def download(_):
        return dcc.send_file(os.path.join(asset_folder, filename))

    dash_dcc.start_server(app)

    # Check that there is nothing before clicking
    fp = os.path.join(dash_dcc.download_path, filename)
    assert not os.path.isfile(fp)

    dash_dcc.find_element("#btn").click()

    # Check that a file has been download, and that it's content matches the original.
    until(lambda: os.path.exists(fp), 10)
    with open(fp, "rb") as f:
        content = f.read()
    with open(os.path.join(asset_folder, filename), "rb") as f:
        original = f.read()
    assert content == original
Exemple #3
0
def render_page_content(pathname):
    # 최초경로 출력
    if pathname == '/':
        return [dbc.Jumbotron([])]
    elif pathname == '/page-1':
        return [
            html.H1('kindergarten in Iran', style={'textAlign': 'center'}),
            dcc.Graph(id='bargraph',
                      figure=px.bar(
                          df,
                          barmode='group',
                          x='Years',
                          y=['Girls Kindergarten', 'Boys Kindergarten']))
        ]
    # 페이지1 출력
    elif pathname == '/page-2':
        return [
            html.H1('Grad School in Iran', style={'textAlign': 'center'}),
            dcc.Graph(id='bargraph',
                      figure=px.bar(
                          df,
                          barmode='group',
                          x='Years',
                          y=['Girls Grade School', 'Boys Grade School']))
        ]
    # 페이지2 출력
    elif pathname == '/page-3':
        return [
            html.H1('High School in Iran', style={'textAlign': 'center'}),
            dcc.Graph(id='bargraph',
                      figure=px.bar(
                          df,
                          barmode='group',
                          x='Years',
                          y=['Girls High School', 'Boys High School']))
        ]

    elif pathname == '/dataframe':
        return [
            html.Div([
                dbc.Button('Download CSV',
                           id='btn_csv',
                           color='primary',
                           style={'margin': '1rem'}),
                dcc.Download(id='download-dataframe-csv'),
                dbc.Table(generate_table(df),
                          bordered=True,
                          dark=True,
                          hover=True,
                          responsive=True,
                          striped=True),
            ])
        ]
    # 에러메세지 발생
    return dbc.Jumbotron([
        html.H1('404:not found', className='text-danger'),
        html.Hr(),
        html.P(f'The pathname {pathname} was not recognised..')
    ])
def clientside_stores(get_uuid: Callable) -> html.Div:
    """Contains the clientside stores"""
    return html.Div(children=[
        dcc.Store(id=get_uuid("selections"), storage_type="session"),
        dcc.Store(id=get_uuid("page-selected"), storage_type="session"),
        dcc.Store(id=get_uuid("voldist-page-selected"),
                  storage_type="session"),
        dcc.Store(id=get_uuid("initial-load-info"), storage_type="memory"),
        html.Div(
            style={"display": "none"},
            children=dcc.Download(id=get_uuid("download-dataframe")),
        ),
    ])
Exemple #5
0
def layout(params):
    return html.Div(id='session-tab-container',
                    children=[
                        html.H2("Session management"),
                        html.Button('New Session',
                                    id='new-session-button',
                                    n_clicks=0),
                        html.H3("Files"),
                        dcc.Dropdown(id='files-dropdown',
                                     options=[],
                                     clearable=False,
                                     style={'color': 'black'}),
                        dcc.Upload(
                            id='data-file-upload',
                            children=html.Div(["Upload File"]),
                            style={
                                "width": "80%",
                                "height": "60px",
                                "lineHeight": "60px",
                                "borderWidth": "1px",
                                "borderStyle": "dashed",
                                "borderRadius": "5px",
                                "textAlign": "center",
                                "position": "center",
                                "margin": "auto",
                                "marginTop": "10px",
                                "marginBottom": "10px",
                            },
                            multiple=False,
                        ),
                        html.Div([
                            html.Button("Download file",
                                        id="file-download-button"),
                            dcc.Download(id="file-download")
                        ]),
                        dcc.Store(id='session-id-store', data='default'),
                        dcc.Store(id='session-files-update-upload-store'),
                        dcc.Store(id='session-files-update-track-store'),
                        dcc.Store(id='session-files-update-postprocess-store',
                                  data=0),
                        dcc.Store(id='session-files-update-image-store',
                                  data=0),
                        dcc.Store(id='session-parameters-store',
                                  data=str(json.dumps(params._params))),
                        dcc.Store(id='session-active-img-file-store', data=""),
                        dcc.Store(id='session-active-info-file-store',
                                  data=""),
                    ])
def test_dldf001_download_dataframe(fmt, dash_dcc):
    df = pd.DataFrame({
        "a": [1, 2, 3, 4],
        "b": [2, 1, 5, 6],
        "c": ["x", "x", "y", "y"]
    })
    reader = getattr(pd, "read_{}".format(fmt))  # e.g. read_csv
    writer = getattr(df, "to_{}".format(fmt))  # e.g. to_csv
    filename = "df.{}".format(fmt)
    # Create app.
    app = dash.Dash(__name__, prevent_initial_callbacks=True)
    app.layout = html.Div(
        [html.Button("Click me", id="btn"),
         dcc.Download(id="download")])

    @app.callback(Output("download", "data"), Input("btn", "n_clicks"))
    def download(_):
        # For csv and html, the index must be removed to preserve the structure.
        if fmt in ["csv", "html", "excel"]:
            return dcc.send_data_frame(writer, filename, index=False)
        # For csv and html, the index must be removed to preserve the structure.
        if fmt in ["stata"]:
            a = dcc.send_data_frame(writer, filename, write_index=False)
            return a
        # For other formats, no modifications are needed.
        return dcc.send_data_frame(writer, filename)

    dash_dcc.start_server(app)

    # Check that there is nothing before clicking
    fp = os.path.join(dash_dcc.download_path, filename)
    assert not os.path.isfile(fp)

    dash_dcc.find_element("#btn").click()

    # Check that a file has been download, and that it's content matches the original data frame.
    until(lambda: os.path.exists(fp), 10)
    df_download = reader(fp)
    if isinstance(df_download, list):
        df_download = df_download[0]
    # For stata data, pandas equals fails. Hence, a custom equals is used instead.
    assert df.columns.equals(df_download.columns)
    assert df.index.equals(df_download.index)
    np.testing.assert_array_equal(df.values, df_download.values)
Exemple #7
0
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = dbc.Container([
    dash_table.DataTable(
        id='table',
        columns=[{
            "name": i,
            "id": i
        } for i in df.columns],
        data=df.to_dict('records'),
    ),
    dbc.Button(id='btn',
               children=[html.I(className="fa fa-download mr-1"), "Download"],
               color="info",
               className="mt-1"),
    dcc.Download(id="download-component"),
],
                           className='m-4')


@app.callback(
    Output("download-component", "data"),
    Input("btn", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dict(content="Always remember, we're better together.",
                filename="hello.txt")
    # return dcc.send_data_frame(df.to_csv, "mydf_csv.csv")
    # return dcc.send_data_frame(df.to_excel, "mydf_excel.xlsx", sheet_name="Sheet_name_1")
    # return dcc.send_file("./assets/data_file.txt")
Exemple #8
0
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc
import pandas as pd

app = dash.Dash(prevent_initial_callbacks=True)
df = pd.read_csv(
    'https://raw.githubusercontent.com/Coding-with-Adam/Dash-by-Plotly/master/Bootstrap/Side-Bar/iranian_students.csv'
)

app.layout = html.Div([
    html.Button('Download CSV', id='btn_csv'),
    dcc.Download(id='download-dataframe-csv')
])


@app.callback(Output('download-dataframe-csv', 'data'),
              Input('btn_csv', 'n_clicks'),
              prevent_initial_call=True)
def download(n_clicks):
    return dcc.send_data_frame(df.to_csv, 'mydf.csv')


if __name__ == '__main__':
    app.run_server()
                   className='text-center'),
    dbc.Row([
        dbc.Col([
            dcc.Markdown(
                ''' *One can type here the some key findings or notewhorty events related to
                            the latest forecast *''')
        ])
    ]),
    dbc.CardFooter(
        html.Div([
            dbc.Button("Download CSV",
                       id='but_download_csv',
                       n_clicks=0,
                       block=True,
                       color='primary'),
            dcc.Download(id="download_df_csv")
        ]))
],
                        className='m-4')

##################### Content  ####################
layout = html.Div([
    dbc.FormGroup([
        dbc.Row([
            dbc.Col([filters, download_csv], width=3),
            dbc.Col(figures, width=9)
        ],
                no_gutters=True)
    ])
])
Exemple #10
0
def render_page_content(pathname):
    if pathname == "/":

        @app.callback(
            Output("download-component", "data"),
            Input("btn", "n_clicks"),
            prevent_initial_call=True,
        )
        def func(n_clicks):
            global df2
            df2 = pd.DataFrame()
            header_list = ['expected', 'Predicted', 'F1Score']
            df2 = df2.reindex(columns=header_list)

            n = df.index[df['F1Score'] > float(0.8)]

            df2 = (df.iloc[n])
            df2['Predicted'] = df2['expected']
            return dcc.send_data_frame(df2.to_csv, "mydf_csv.csv")
        return[dash_table.DataTable(
        persistence=True,
        persistence_type='memory',
        id='table-dropdown',
        data=df.to_dict('records'),

            #the contents of the table
        fixed_rows={'headers': True},

        columns=[
            {'id': 'expected', 'name': 'expected','editable':True, 'presentation': 'dropdown'},
            {'id': 'Predicted', 'name': 'Predicted','editable':True,'presentation': 'dropdown'},
            {'id': 'F1Score', 'name': 'F1Score'},
            {'id': 'Accept','name': 'Accept','editable':True,'presentation': 'dropdown'},
            {'id': 'Change','name':'Change','editable':True,'presentation': 'dropdown'}
        ],

        style_table={'height': 900},
        style_header={'backgroundColor': 'rgb(30, 30, 30)','color':'white'},
        style_cell={'minWidth':95,'width':95,'maxWidth':95,'text-align':'center'},
        editable=True,

        dropdown={                      #dictionary of keys that represent column IDs,
            'expected': {                #its values are 'options' and 'clearable'
                'options': [            #'options' represents all rows' data under that column
                    {'label': i, 'value': i}
                    for i in df['expected'].unique()
                ],

                'clearable':True,
            },
            'Predicted': {
                'options':[
                    {'label': i, 'value': i}
                    for i in df['Predicted'].unique()
                ],

                'clearable':True,
            },
            'Accept':{
                'options':[
                    {"label":"☑", "value": "checked"},
                    {"label": "☐", "value": "unchecked"}
                    #for i in df['Accept']
                ],
                "clearable": True,
            },
            'Change':{
                'options':[
                    {"label":"☑ ", "value": "checked"},
                    {"label": "☐", "value": "unchecked"},
                ],
                "clearable": False,

        }


        }),
        dbc.Checklist(id='Tick',
        options=[
            {'label': 'Tick on the box to save the changes', 'value':'sav'},

            ]

            )  ,
        dbc.Container(
            [
                dbc.Button(id='btn',
                children=[html.I(className="fa fa-download mr-1"), "Download"],
                color="info",
                className="mt-1"
                ),

            dcc.ConfirmDialog(id="confirm",message="Changes saved,Click on download"),
            dcc.Download(id="download-component")],className='m-4')]

    elif pathname == "/page-1":

        pass

    elif pathname == "/page-2":
        pass
    # If the user tries to reach a different page, return a 404 message
    return dbc.Jumbotron([
        html.H1("404: Not found", className="text-danger"),
        html.Hr(),
        html.P(f"The pathname {pathname} was not recognised..."),
    ])
Exemple #11
0
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(prevent_initial_callbacks=True, )
app.layout = html.Div([
    html.Button("Download Image", id="btn_image"),
    dcc.Download(id="download-image")
])


@app.callback(
    Output("download-image", "data"),
    Input("btn_image", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dcc.send_file(
        "./dash_docs/assets/images/gallery/dash-community-components.png")


if __name__ == "__main__":
    app.run_server(debug=True)
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(prevent_initial_callbacks=True)
app.layout = html.Div(
    [
        html.Button("Download CSV", id="btn_csv"),
        dcc.Download(id="download-dataframe-csv"),
    ]
)

import pandas as pd

df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [2, 1, 5, 6], "c": ["x", "x", "y", "y"]})


@app.callback(
    Output("download-dataframe-csv", "data"),
    Input("btn_csv", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dcc.send_data_frame(df.to_csv, "mydf.csv")


if __name__ == "__main__":
    app.run_server(debug=True)
Exemple #13
0
                                                "label": "linear y axis",
                                                "value": "linear"
                                            },
                                        ],
                                        value="log",
                                        id="yaxis_scale",
                                        labelStyle={"display": "inline-block"},
                                    ), )
                            ])
                        ],
                        style={"width": "100%"},
                    ),
                    dcc.Loading(id="loading-1",
                                type="default",
                                children=html.Div(id="graph_container")),
                    dcc.Download(id="download-text"),
                ] + footer),
            dcc.Tab(label='From MCNP material card', value='tab-2'),
        ]),
    html.Div(id='tab-2-content'),
    dcc.Download(id="download-text-mcnp"),
])


@app.callback(Output('tab-2-content', 'children'), Input('tabs', 'value'))
def render_content(tab):
    if tab == 'tab-2':
        return html.Div([
            html.Div([
                html.H3([" \U00002702 Copy a material card in MCNP format"],
                        style={'text-align': 'center'}),
Exemple #14
0
                                dcc.Store(id='store_df_filtered_borough'),
                                dcc.Store(id='store_df_filtered_health'),
                                dcc.Store(id='store_df_graph_select'),]),

                    
                ], className='three columns'),

                html.Div([

                    ## Export section
                    html.H3('Export data'),

                    html.H6('Complete data set'),
                    
                    html.Button("Download CSV", id="btn_all_csv"),
                    dcc.Download(id="download_dataframe_all_csv"),
                    
                    html.Button("Download XLSX", id="btn_all_xlsx"),
                    dcc.Download(id="download_dataframe_all_xlsx"),

                    html.Br(),
                    html.Br(),

                    html.H6('Filtered data set'),
                    
                    html.Button("Download CSV", id="btn_filtered_csv"),
                    dcc.Download(id="download_dataframe_filtered_csv"),
                    
                    html.Button("Download XLSX", id="btn_filtered_xlsx"),
                    dcc.Download(id="download_dataframe_filtered_xlsx"),
                    
Exemple #15
0
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(prevent_initial_callbacks=True)
app.layout = html.Div([
    html.Button("Download Excel", id="btn_xlxs"),
    dcc.Download(id="download-dataframe-xlxs-index"),
])

import pandas as pd
import xlsxwriter

df = pd.DataFrame({
    "a": [1, 2, 3, 4],
    "b": [2, 1, 5, 6],
    "c": ["x", "x", "y", "y"]
})


@app.callback(
    Output("download-dataframe-xlxs-index", "data"),
    Input("btn_xlxs", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dcc.send_data_frame(df.to_excel,
                               "mydf.xlxs",
                               sheet_name="Sheet_name_1")
Exemple #16
0
                                children=[
                                    html.
                                    P("New golf shot data can be saved below, either by inputing them one at a time or by uploading a file with multiple shots."
                                      ),
                                    html.
                                    P("Press the download button to get a spreadsheet for logging shots in."
                                      )
                                ]),

                            # Download button
                            html.Div(className="flex",
                                     children=[
                                         html.Button("Download PDF",
                                                     id="download_btn_id",
                                                     className="btn"),
                                         dcc.Download(id='download_id'),
                                         html.Button("Refresh Data",
                                                     id="refresh_btn_id",
                                                     className="btn"),
                                     ])
                        ])
                ]),
            html.Div(
                className="data-upload grid grid-2",
                children=[

                    # UPLOAD BOX
                    html.Div(
                        className="upload-box",
                        children=[
                            html.Div(
Exemple #17
0
def applyAlgo(algo, apply_click, batch_click):

    ctx = dash.callback_context
    triggerCause = ctx.triggered[0]['prop_id'].split('.')[0]

    if (triggerCause == 'algorithm-dropdown' or triggerCause == 'apply_algo'):
        if (algo == None):
            g_var.algoInstance = None
            raise PreventUpdate

        g_var.algoInstance = globals()[algo]

        if (g_var.datasetInstance == None):
            raise PreventUpdate

        fig = None
        img_detections = None
        table_header = [
            html.Thead(
                html.Tr([
                    html.Th("Detected Object"),
                    html.Th("Accuracy"),
                    html.Th("x0"),
                    html.Th("y0"),
                    html.Th("width"),
                    html.Th("height")
                ]))
        ]
        table_body = None
        if (g_var.datasetInstance != None):
            curr_img = g_var.datasetInstance.getCurrImage(cv2=True)
            img_detections = g_var.algoInstance.detect_image_file(curr_img)
            fig = go.Figure(px.imshow(img_detections[1]))
            colors = g_var.algoInstance.get_colors()
            rows = []
            for detect in img_detections[0]:
                category = detect[0]
                fig.add_shape(
                    type="rect",
                    x0=detect[2][0] - (int(detect[2][2]) / 2),
                    y0=detect[2][1] - (int(detect[2][3]) / 2),
                    x1=detect[2][0] + (int(detect[2][2]) / 2),
                    y1=detect[2][1] + (int(detect[2][3]) / 2),
                    line=dict(
                        color='rgb' + str(colors[category]),
                        width=2,
                    ),
                )
                fig.add_annotation(
                    x=detect[2][0] - (int(detect[2][2]) / 2),
                    y=detect[2][1] - (int(detect[2][3]) / 2),
                    text=category + " [" + detect[1] + "]",
                    showarrow=False,
                    font=dict(size=16, color="#ffffff"),
                    align="center",
                    opacity=1,
                    bgcolor="#000000",
                )
                rows.append(
                    html.Tr([
                        html.Td(detect[0]),
                        html.Td(detect[1]),
                        html.Td(detect[2][0]),
                        html.Td(detect[2][1]),
                        html.Td(detect[2][2]),
                        html.Td(detect[2][3])
                    ]))
            table_body = [html.Tbody(rows)]
        table = dbc.Table(table_header + table_body, bordered=True)
        return [fig, table, "Detection Results", True]

    if (triggerCause == 'batch_apply_algo'):
        if (g_var.algoInstance == None or g_var.datasetInstance == None):
            raise PreventUpdate

        img_detections = g_var.algoInstance.batch_detect(
            g_var.datasetInstance.getBatchImages(cv2=True, getNames=True),
            dirPath=g_var.download_dir)
        table_header = [
            html.Thead(
                html.Tr([
                    html.Th("Image Name"),
                    html.Th("Detected Object"),
                    html.Th("Accuracy"),
                    html.Th("x0"),
                    html.Th("y0"),
                    html.Th("width"),
                    html.Th("height")
                ]))
        ]
        rows = []
        for image in img_detections:
            for detect in image["bbox"]:
                rows.append(
                    html.Tr([
                        html.Td(image["image_name"]),
                        html.Td(detect[0]),
                        html.Td(detect[1]),
                        html.Td(detect[2][0]),
                        html.Td(detect[2][1]),
                        html.Td(detect[2][2]),
                        html.Td(detect[2][3])
                    ]))
        table_body = [html.Tbody(rows)]
        table = dbc.Table(table_header + table_body, bordered=True)

        buttons = html.Div(
            [  #Download Buttons row
                html.Div([
                    dbc.Button(
                        "Download Current Results as JSON",
                        id="download_json",
                        color='dark',
                        className='mr-1 mb-1',
                    ),
                    dbc.Button(
                        "Download Current Detected Images as zip",
                        id="download_zip",
                        color='dark',
                        className='mr-1 mb-1',
                    ),
                    dbc.Button(
                        "Download All Results as JSON",
                        id="download_json_all",
                        color='dark',
                        className='mr-1 mb-1',
                    ),
                    dbc.Button(
                        "Download All Detected Images as zip",
                        id="download_zip_all",
                        color='dark',
                        className='mr-1 mb-1',
                    ),
                    dcc.Download(id="download-results"),
                ],
                         className='col-12'),
            ],
            className='row')

        return [dash.no_update, [buttons, table], "Batch Apply Results", True]

    else:
        raise PreventUpdate
Exemple #18
0
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(prevent_initial_callbacks=True)
app.layout = html.Div([
    html.Button("Download Text", id="btn_txt"),
    dcc.Download(id="download-text")
])


@app.callback(
    Output("download-text", "data"),
    Input("btn_txt", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dict(content="Hello world!", filename="hello.txt")


if __name__ == "__main__":
    app.run_server(debug=True)
Exemple #19
0
subdim = subspace.subspace_dimension
W = subspace.get_subspace()[:,:subdim]
subpoly = subspace.get_subspace_polynomial()
Xnorm = scaler.transform(Xorig)
ypred = subpoly.get_polyfit(Xnorm @ W)
```
'''

downloads = dbc.Container([
    dbc.Row(dbc.Col([
        dbc.Button("Download reduced data",
                   id="download-csv-button",
                   color='primary',
                   className='py-0',
                   disabled=True),
        dcc.Download(id="download-csv")
    ],
                    width='auto'),
            style={'margin-top': '10px'}),
    dbc.Row(
        dbc.Col(dcc.Markdown(
            '*.csv* file containing the training data in its reduced dimensional form.',
            style={'text-align': 'justify'}),
                width='auto')),
    dbc.Row([
        dbc.Col([
            dbc.Button("Download subspace",
                       id="download-subspace-button",
                       color='primary',
                       className='py-0',
                       disabled=True),
Exemple #20
0
def render_page_content(pathname):
    # 최초경로 출력
    if pathname == '/':
        return [dbc.Jumbotron(['###안녕하세요###'])]
    # 페이지1 출력
    elif pathname == '/page-1':
        return [
            html.H1('카테고리별 평균 목표금액', style={'textAlign': 'center'}),
            multiple_input
        ]

    # 페이지2 출력
    elif pathname == '/page-2':

        return [
            html.H1('Grad School in Iran', style={'textAlign': 'center'}),
            dcc.Graph(year_df,
                      id='bar-graph',
                      x='funding_amounts',
                      y="target_amounts")
        ]

    # 페이지3 출력
    elif pathname == '/page-3':
        return [
            html.Div([
                dcc.Input(id='username', value='Initial Value', type='text'),
                html.Button(id='submit-button',
                            type='submit',
                            children='Submit'),
                html.Div(id='output_div')
            ])
        ]

    # 페이지4 출력
    elif pathname == '/dataframe':

        return [
            html.Div([
                dbc.Button('Download CSV',
                           id='btn_csv',
                           color='primary',
                           style={'margin': '1rem'}),
                dcc.Download(id='download-dataframe-csv'),
                dbc.Table(generate_table(df, 5),
                          bordered=True,
                          dark=True,
                          hover=True,
                          responsive=True,
                          striped=True),
            ])
        ]

    elif pathname == '/system':
        # cate = str(request.form['cateinput'])
        types = ['text']
        return [
            html.Div([
                dbc.FormGroup([
                    dbc.Input(id=f'my_{x}',
                              value='립밤',
                              placeholder='Enter category',
                              type=f'{x}') for x in types
                ]),
                dbc.Table(id='update-dataframe')
            ])
        ]

    # dbc.FormGroup([
    #     dbc.Label('카테고리 입력', html_for='cate-input'),
    #     dbc.Input(id=f'my_{x}', value='립밤', placeholder='Enter category', type=f'{x}') for x in types,
    #     dbc.FormText('카테고리를 입력하세요', color='secondary')
    # ]),

    else:
        # 에러메세지 출력
        return dbc.Jumbotron([
            html.H1('404:not found', className='text-danger'),
            html.Hr(),
            html.P(f'The pathname {pathname} was not recognised..')
        ])
Exemple #21
0
                     {'name': 'Logged Date Time', 'id': 'Logged Date Time'}
                    ],
            style_cell={'textAlign': 'left', 'textOverflow': 'ellipsis', 'minWidth': '20px', 'maxWidth': '400px'},
            style_table={'overflowX': 'auto', 'overflowY': 'auto'},
            page_size=10,
            style_header={'fontWeight': 'bold', 'backgroundColor': '#c799b9', 'fontFamily': 'Calibri', 'fontStyle': 'italic'},
            style_data={'fontFamily': 'Calibri'},
            style_data_conditional=[{'if': {'row_index': 'odd'}, 'backgroundColor': 'rgb(248, 248, 248)'}]
    )],
            id='workLog-dataTable',
            style={'marginLeft': '20px', 'marginRight': '20px'}
    ),

    html.Br(),

    html.Div([html.Span([html.Button("Download Summary", id="summaryFile"), dcc.Download(id="downloadSummaryFile")], style={'marginLeft': '10%'})]),

    html.Br(),
    html.Br(),

    html.Div([
        dcc.Dropdown(
            id = 'names', 
            options = option, 
            placeholder = 'Select user', 
            multi = True
        )
    ],
        style = {'display' : 'inline-block', 'verticalAlign' : 'top', 'width' : '30%', 'marginLeft': '20px'}
    ),
    
                     children=html.Div(id="loading_graph_output"),
                     style={
                         'text-justify': 'right',
                         'padding-bottom': '2em'
                     })
     ],
              style={
                  'padding-bottom': '2em',
                  'padding-top': '1.5em'
              }),
     html.Div(children=[
         html.Button(id='generate_txt_file',
                     n_clicks=0,
                     children='Press to download a txt file '
                     'of all nodes in the graph!'),
         dcc.Download(id='txt_download', children='Pls Work'),
         dcc.Loading(id="loading_file",
                     type="circle",
                     children=html.Div(id="loading_file_output"),
                     style={
                         'text-justify': 'right',
                         'padding-left': '15em',
                         'padding-bottom': '1em'
                     })
     ],
              style={'padding-bottom': '2em'})
 ],
 style={
     'width': '27%',
     'float': 'left',
     'padding': '.5em .5em .5em .5em',
Exemple #23
0
            ),
            # TABLE
            html.Div(
                children=[
                    TAB3_BODY_CONTENT2
                ],
                className="w-100 h-100 px-4"
            ),
            dcc.Store(id='DATA_TABLE_WELL_STORE-TAB3_BODY_CONTENT2'),
            # DOWNLOAD BUTTON
            html.Div(
                children=[
                    html.Button(
                        children=[
                            "دانلود",
                            html.I(className="fa fa-download ml-2"),
                        ],
                        n_clicks=0,
                        className="btn btn-outline-dark mt-3 float-right",
                        id="DOWNLOAD_TABLE_BUTTON-TAB3_BODY_CONTENT2"
                    ),
                    dcc.Download(id="DOWNLOAD_TABLE_COMPONENT-TAB3_BODY_CONTENT2"),
                ],
                className="row justify-content-center"
            ),

        ],
        className="row justify-content-center"
    )
]
Exemple #24
0
    #     ),
    #     html.Button('Add Column', id='editing-columns-button', n_clicks=0)
    # ], style={'height': 50}),

    html.Div(id='confirmed-rule-table'),
    html.Div(id='export-message'),
    dbc.Button(
            "Export",
            # color="link",
            color="primary",
            id='export-button',
            style={
                'display':'inline-block'
            }
        ),
    dcc.Download(id='download-content'),
    dcc.Download(id='download-decision-dataframe'),
    # dbc.Button(
    #         'Save',
    #         id='save-decision-button',
    #         color="primary"
    #     ),
    dbc.Button(
            "Apply",
            # color="link",
            color="success",
            id='apply-button',
            style={
                'display': 'inline-block'
            }
        ),
Exemple #25
0
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(prevent_initial_callbacks=True)

app.layout = html.Div([
    html.Button("Download Text", id="btn_txt"),
    dcc.Download(id="download-text-index")
])


@app.callback(Output("download-text-index", "data"),
              Input("btn_txt", "n_clicks"))
def func(n_clicks):
    if n_clicks is None:
        raise dash.exceptions.PreventUpdate
    else:
        return dict(content="Hello world!", filename="hello.txt")


if __name__ == "__main__":
    app.run_server(debug=True)
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash(prevent_initial_callbacks=True)
app.layout = html.Div([
    html.Button("Download Excel", id="btn_xlxs"),
    dcc.Download(id="download-dataframe-xlxs"),
])

import pandas as pd
import xlsxwriter

df = pd.DataFrame({
    "a": [1, 2, 3, 4],
    "b": [2, 1, 5, 6],
    "c": ["x", "x", "y", "y"]
})


@app.callback(
    Output("download-dataframe-xlxs", "data"),
    Input("btn_xlxs", "n_clicks"),
    prevent_initial_call=True,
)
def func(n_clicks):
    return dcc.send_data_frame(df.to_excel,
                               "mydf.xlxs",
                               sheet_name="Sheet_name_1")
Exemple #27
0
def build_layout(params):
    return html.Div([
        NAVBAR,
        dbc.Row(
            dbc.Col([
                html.H1("Visualizador", className="mt-2"),
                dbc.Button(
                    "Ocultar selección",
                    id="collapse-button",
                    size="sm",
                    color="secondary",
                    className="float-right mb-0 ml-0",
                ),
                dbc.Collapse(form_tabs(params), id="collapse", is_open=True),
            ]),
            className="mx-0 mx-md-3",
        ),
        dcc.Store(id="final-data"),
        dcc.Store(id="final-metadata"),
        dbc.Row(
            dbc.Card([
                dbc.CardHeader(html.H6("Opciones de gráfico"),
                               className="p-2"),
                dbc.CardBody(
                    [
                        dbc.Row([
                            dbc.Col([
                                dbc.Label("Tipo de gráfico"),
                                html.Div(
                                    apply_qs(params)(dcc.Dropdown)(
                                        options=[
                                            {
                                                "label": "Líneas",
                                                "value": "line",
                                            },
                                            {
                                                "label": "Barras",
                                                "value": "bar",
                                            },
                                            {
                                                "label": "Barras apiladas",
                                                "value": "stackbar",
                                            },
                                            {
                                                "label": "Áreas",
                                                "value": "area",
                                            },
                                            {
                                                "label": "Proporciones",
                                                "value": "normarea",
                                            },
                                            {
                                                "label": "Líneas-año",
                                                "value": "lineyears",
                                            },
                                            {
                                                "label": "Tabla",
                                                "value": "table",
                                            },
                                        ],
                                        id="chart-type",
                                        value="line",
                                        clearable=False,
                                    ),
                                    className="dash-bootstrap",
                                ),
                            ]),
                            dbc.Col([
                                apply_qs(params)(dbc.Input)(
                                    id="chart-title",
                                    placeholder="Título",
                                    debounce=True,
                                    type="text",
                                ),
                                apply_qs(params)(dbc.Input)(
                                    id="chart-subtitle",
                                    placeholder="Subtítulo",
                                    debounce=True,
                                    type="text",
                                    className="mt-1",
                                ),
                            ]),
                        ]),
                        dbc.Form(
                            dbc.FormGroup([
                                dbc.Label(
                                    "Fechas",
                                    html_for="chart-dates",
                                    className="mr-2",
                                ),
                                apply_qs(params)(dcc.DatePickerRange)(
                                    start_date_placeholder_text="Inicial",
                                    end_date_placeholder_text="Final",
                                    display_format="DD-MM-YYYY",
                                    clearable=True,
                                    className="dash-bootstrap",
                                    id="chart-dates",
                                ),
                            ]),
                            className="row mt-2 mx-2 justify-content-center",
                        ),
                    ],
                    className="p-2",
                ),
            ]),
            className="mx-3 mt-2 justify-content-center",
        ),
        dbc.Row(
            dbc.Col(
                dbc.Spinner(dcc.Graph(), id="graph-spinner", color="primary")),
            className="mx-0 mx-md-3",
        ),
        dbc.Row(
            [
                dbc.Col(
                    dbc.Button(
                        "Descargar Excel",
                        id="xlsx-button",
                        color="primary",
                        disabled=True,
                    ),
                    className="text-center mb-2",
                    md=2,
                ),
                dbc.Col(
                    dbc.Button(
                        "Descargar CSV",
                        id="csv-button",
                        color="primary",
                        disabled=True,
                    ),
                    className="text-center mb-2",
                    md=2,
                ),
                dbc.Col(
                    [
                        dcc.Clipboard(
                            target_id="html-div",
                            id="clipboard",
                            className="d-inline btn btn-primary disabled",
                        ),
                        html.Div("Copiar HTML", className="d-inline ml-2"),
                    ],
                    className="text-center mb-2",
                    md=2,
                    align="center",
                ),
            ],
            justify="center",
            className="mx-0 mx-md-3",
            no_gutters=True,
        ),
        html.Div(id="html-div", hidden=True),
        dcc.Download(id="download-data-csv"),
        dcc.Download(id="download-data-xlsx"),
        metadata_notes(),
        html.Div(id="dummy"),
        html.Br(),
        FOOTER,
    ])