Dash: Two Graphs side by side in a Dashboard

Created on 21 Sep 2017  路  4Comments  路  Source: plotly/dash

The following code diplay charts one-below-another, I want them side by side

app.layout = html.Div(children=[
    dcc.Graph(
    figure= dsf.customChart1(Data=Data, attribution=['Gender','JobType'], title='Gender Distribution'),
    style={'width': '800'}
        ),
    dcc.Graph(
    figure=dsf.customChart2(Data=Data, xd='Age',yd='Salary', attribution=['Gender','JobType'],
                     title='Some Title' , color_att=['Gender']),
            style={'width': '800'}),
], style={'width': '100%', 'display': 'inline-block'})

Most helpful comment

Hi, Something like this should do the trick for you:

app.layout = html.Div(children=[
    html.Div(
        dcc.Graph(
            figure= dsf.customChart1(Data=Data, attribution=['Gender','JobType'], title='Gender Distribution'),
            style={'width': '800'}
        ), style={'display': 'inline-block'}),
    html.Div(
        dcc.Graph(
            figure=dsf.customChart2(Data=Data, xd='Age',yd='Salary', attribution=['Gender','JobType'],
                     title='Some Title' , color_att=['Gender']),
            style={'width': '800'}
        ), style={'display': 'inline-block'})
], style={'width': '100%', 'display': 'inline-block'})

You might have to remove the style={'width': '800'}, as this will cause the elements to wrap if the display is not wide enough (i.e., greater than ~1600px + margins)

Other options would include using a the rows/columns technique of a grid layout system like Bootstrap, though this will require the addition of an additional CSS sheet.

All 4 comments

Hi, Something like this should do the trick for you:

app.layout = html.Div(children=[
    html.Div(
        dcc.Graph(
            figure= dsf.customChart1(Data=Data, attribution=['Gender','JobType'], title='Gender Distribution'),
            style={'width': '800'}
        ), style={'display': 'inline-block'}),
    html.Div(
        dcc.Graph(
            figure=dsf.customChart2(Data=Data, xd='Age',yd='Salary', attribution=['Gender','JobType'],
                     title='Some Title' , color_att=['Gender']),
            style={'width': '800'}
        ), style={'display': 'inline-block'})
], style={'width': '100%', 'display': 'inline-block'})

You might have to remove the style={'width': '800'}, as this will cause the elements to wrap if the display is not wide enough (i.e., greater than ~1600px + margins)

Other options would include using a the rows/columns technique of a grid layout system like Bootstrap, though this will require the addition of an additional CSS sheet.

Thank you

Thank you, this really works for me

Does this also work for html images? This is what I tried:

html.Div(
        html.Img(src='data:image/png;base64,{}'.format(encoded_image.decode()), width=400, height=300),
        style={'display': 'inline-block'}
    ),

    html.Div(id='output_container', children=[],style={'display': 'inline-block'}),
    html.Div(
        dcc.Graph(id='experimental_lakes', figure={}),
        style={'display': 'inline-block'}
    )

But my graph is still beneath my image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mondrik picture Mondrik  路  3Comments

ninjakx picture ninjakx  路  3Comments

hscspring picture hscspring  路  4Comments

T4rk1n picture T4rk1n  路  3Comments

maartenbreddels picture maartenbreddels  路  4Comments