Два DatePicker в одном обратном вызове Da sh Plotly Python - PullRequest
0 голосов
/ 03 апреля 2020

Я пытаюсь установить 2 средства выбора даты в одном обратном вызове, цель этого состоит в том, чтобы создать график с двумя фреймами данных, один из которых соответствует фильтру с первым раскрывающимся списком, а второй - вводит вторую дату фильтр.

Ive следующий код: (Я просто собираюсь поместить часть кода, потому что он довольно большой)

cluster = dbc.Form([
        dbc.FormGroup([
                dbc.Label('Dasboard Visión de Negocios (COVID-19)', html_for="dropdown",style={'font-family': 'arial','font-size': '2rem'}),
                dbc.Row([
# =============================================================================
#                     # Fila de dropdowns
# =============================================================================
                        dbc.Col([
                                #####  TIME PERIOD
                                dbc.Label('Periodo:', html_for="dropdown",style={'padding-top': '80px','font-family': 'arial','font-size': '1.1rem'}),
                                dcc.DatePickerRange(id='periodo_sel',
                                                    display_format='DD MMM YYYY',
                                                    minimum_nights=1,
                                                    start_date=dt(2019,1,1),
                                                    end_date=df['EFFECTIVE_START_DATE'].max(),
                                                    style={'width': 'max-content','font-family': 'arial'},
                                                    day_size = 30),
                                ##### SECOND TIME PERIOD
                                dbc.Label('Periodo 2:', html_for="dropdown",style={'padding-top': '80px','font-family': 'arial','font-size': '1.3rem'}),
                                dcc.DatePickerRange(id='periodo_sel2',
                                                    display_format='DD MMM YYYY',
                                                    minimum_nights=1,
                                                    start_date=dt(2019,1,1),
                                                    end_date=df['EFFECTIVE_START_DATE'].max(),
                                                    style={'width': 'max-content','font-family': 'arial'},
                                                    day_size = 30),
......      

Здесь я пытаюсь создать участок:

@app.callback(Output(component_id='product_graph', component_property='figure'),
              [Input('periodo_sel','start_date'),
               Input('periodo_sel','end_date'),
               Input('periodo_sel2','start_date'),
               Input('periodo_sel2','end_date'),
               Input('periodo_sel','end_date'),
               Input('temp_select','value'),
               Input('product_select','value')])

def product_plot(start_date, end_date, temp_select, product_select):
    """
    Here is where the problem begins, because I don't know how to set a "start2" and "end2", if          you see, period has only start and end as property, so when I'm trying to set the second period it becomes redundant and takes the input of the first output
    """
    start = pd.to_datetime(start_date)
    end = pd.to_datetime(end_date)

    start2 = pd.to_datetime(?????)
    end2 = pd.to_datetime(?????)


....
...