0

I found one HTML template that fits the dashboard very well. In the beginning, I figured out how to display and update the graph. Then, while posting the page, I ran into the problem of building HTML in Plotly Dash. HTML structure

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h4 class="card-title">CARD_ONE</h4>
                <a class="heading-elements-toggle"><i class="la la-ellipsis-v font-medium-3"></i></a>
                <div class="heading-elements">
                    <ul class="list-inline mb-0">
                        <li><a data-action="collapse"><i class="ft-minus"></i></a></li>
                        <li><a data-action="expand"><i class="ft-maximize"></i></a></li>
                    </ul>
                </div>
            </div>
            <div class="card-content collapse show">
                <div class="card-body chartjs">
                  !!! dash chart !!!  <canvas id="line-chart" height="500"></canvas>
                </div>
            </div>
        </div>
    </div>
</div>

Can't figure out the plot structure in Plotly Dash.

code dash.

def serve_layout():
    return html.Div(
        children=[
            html.H4(children='OWERVIEW'),
            html.Div(id='my-id', className='card', children='''ONE_CARD'''),
            html.Div(className='card-header'),
            html.H4(className="card-title", children='ONE_CARD??'),
            html.Div(className='heading-elements-toggle'),
            html.Div(className='heading-elements'),
            html.Div(className="list-inline mb-0"),
            dcc.Graph(id='example-graph', animate=True, responsive=True),
            dcc.Interval(
                id='interval-component',
                interval=3 * 1000,
                n_intervals=0,
            ),
        ],
    )

All the components in the code are executed line by line and the entire HTML structure does not look like this.

Question: What should the HTML structure look like in Dash Plotly code?

1 Answer 1

1

You'll need to add IDs to some components, and they can be whatever. Not quite sure about the data-action part, though. Overall, it should look like this:

def serve_layout():
    return html.Div(className='row', children=[
        html.Div(className='col-12', children=[
            html.Div(className='card', children=[
                html.Div(className='card-header', children=[
                    html.Div(id='my-id', className='card', children='''ONE_CARD'''),
                    html.A(className='header-elements-toggle', children=html.I(className='la la-ellipsis-v font-medium-3'))
                    html.Div(className='heading-elements', children=[
                        html.Ul(className='list-inline mb-0', children=[
                            html.Li(html.A(html.I(className='ft-minus'))),
                            html.Li(html.A(html.I(className='ft-maximize'))),
                        ]),
                    ]),
                ]),
                html.Div(className='card-content collapse show', children=[
                    html.Div(className='card-body chartjs', children=[
                        dcc.Graph(id='example-graph', animate=True, responsive=True),
                        dcc.Interval(
                            id='interval-component',
                            interval=3 * 1000,
                            n_intervals=0,
                        ),
                    ]),
                ]),
            ]),
        ]),
    ]),
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer, "data-action" is required for the card, the structure of which is above in my question. The card has actions: increase or decrease.
You could use a different component to get expanding and collapsing cards. I've built one as part of this package for Dash.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.