有没有办法在两个不同的破折号标签中运行成品Dash应用程序?

时间:2019-05-09 07:20:48

标签: python callback tabs plotly hyphen

我编写了一个Dash App,用户可以在其中上传CSV文件并将其显示为图形。它还包含某些回调,这些回调会在单击图形时更改图形中条形的颜色,从而推销表中选定的行。现在的问题是我如何在两个不同的“ Dash”选项卡中运行我的应用程序,例如,您可以使用两个上载的CSV文件并进行比较以得到更好的概述。

我已经尝试将我的应用程序分成如下所示的项目结构。

- app.py
- index.py
- apps
   |-- __init__.py
   |-- app1.py
   |-- app2.py

但这真的需要吗?我是否需要连接app.py中的回调,尤其是其中的哪一个才能再次运行我的应用程序?

import base64
import dash_core_components as dcc
import dash_html_components as html
import dash_table_experiments as dt
from dash.dependencies import Input, Output, State
import dash
import pandas as pd
import io


app = dash.Dash()

app.scripts.config.serve_locally = True
app.config['suppress_callback_exceptions'] = True
image_filename = ---
encoded_image = base64.b64encode(open(image_filename, 'rb').read())

app.layout = html.Div([
    dcc.Upload(
        id='upload-data',
        children=html.Div([
            'Drag and drop',
            html.A('Select Files')
        ]),
        style={
            'width': '100%',
            'height': '60px',
            'lineHeight': '60px',
            'borderWidth': '1px',
            'borderStyle': 'dashed',
            'borderRadius': '5px',
            'textAlign': 'center',
            'margin': '10px'
        },

    ),

    html.Br(),
    html.Div("x axis"),
    dcc.Dropdown(id='x_Axis',
        multi = False,

    html.Div('y axis'),
    dcc.Dropdown(id='y_Axis',
        multi = True,


    html.Div(id='graph'),
    html.Br(),
    html.H5("Updated Table"),
    html.Div(dt.DataTable(rows=[{}], id='table', 
                          selected_row_indices=[], row_selectable=True))

    ])


# functions

# file upload function
def parse_contents():

#return graph function
return graph():

# colorchange
@app.callback
def update_selected_row_indices():

#update graph
@app.callback
def update_graph():

# callback table creation
@app.callback
def update_output():

#callback x dropdown
@app.callback
def updateX():

#callback y dropdown
@app.callback
def updateY():

0 个答案:

没有答案