matthewr
matthewr

Reputation: 324

Print in def update_graph()

Sorry this might seem abit basic but how do i show a print in a def update() for a plotly dashboard?

I want to see the type of the output for my datepickerrange() but everytime I run it with other variations I cant seem to print anything on the dashboard, is there an alternate way to call the variable into the environment so i can find out more?

app = dash.Dash()

app.layout = html.Div([

    dcc.DatePickerRange(
        id='my-date-picker-range',
        min_date_allowed=dt(2019, 4, 1),
        max_date_allowed=dt(2019, 6, 30),
        initial_visible_month=dt(2019, 4, 1),
        end_date=dt(2019, 4, 2)
    ),
    html.Div(id='output-container-date-picker-range')
])


@app.callback(
    dash.dependencies.Output('output-container-date-picker-range', 'children'),
    [dash.dependencies.Input('my-date-picker-range', 'start_date'),
     dash.dependencies.Input('my-date-picker-range', 'end_date')]) 


def update_output(start_date, end_date):
    pref= type(start_date)
    return print(pref)

if __name__ == '__main__':
    app.run_server()

Upvotes: 0

Views: 182

Answers (1)

James
James

Reputation: 36598

The print function outputs to the STDOUT channel the str method of whichever objects you pass in.

Instead of:

return print(pref)

Use:

return str(pref)

Upvotes: 2

Related Questions