Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Not able to show px.timeline on Dashboard

$
0
0

Hello, I am trying to add a px.timeline to my dashboard with callback function in order to update the timeline based on filtering. However, I am not really familiar with the callbacks with px graphs and it does not show on my dashboard even though I think I correctly assign the callback functions. Here is part of my code (I did not put irrelevant part):

#----------App layout----------------------------------------------------------------------

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

app.layout = dbc.Container([
  
    html.Div([

        html.H2('Timelines', className="second-section-title"),

        dcc.Graph(id='timeline')

        ]),

    ])


#----------Callback for timeline graphs------------------------------------------------------------

@app.callback(

    [Output('timeline', 'figure')],

    [Input('input_subject','value')]

)

def update_timeline_graph(input_subject):

    # when there is no subject chosen

    if input_subject is None:

        dff = timeline_data

    else:

        dff = timeline_data[timeline_data == input_subject]

       

    timeline_graph = px.timeline(dff,

                                 x_start="Start",

                                 x_end="End",

                                 y="Subject",

                                 color='Type')

   

    timeline_graph.update_xaxes(tickformat="%H:%M:%S",

                                tickformatstops=[dict(dtickrange=[1800000, 10800000], value="%H:%M")])

   

    timeline_graph.update_yaxes(categoryorder="category ascending")

   

    timeline_graph.update_layout({'plot_bgcolor': 'rgba(0, 0, 0, 0)',

                                  'paper_bgcolor': 'rgba(0, 0, 0, 0)'})

   

    return (timeline_graph)

I don’t not really know how it is wrong since I followed the examples I found online

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images