Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show 2 graphs on 1 page #151

Closed
bainadeashish opened this issue Oct 30, 2017 · 1 comment
Closed

How to show 2 graphs on 1 page #151

bainadeashish opened this issue Oct 30, 2017 · 1 comment

Comments

@bainadeashish
Copy link

I have written 2 DIV like below

app.layout = html.Div(children=[
html.H1(children='Hello Dash'),

html.Div(children='''
    Dash: A web application framework for Python.
'''),

dcc.Graph(
    id='example-graph',
    figure={
        'data': [
            {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
            {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
        ],
        'layout': {
            'title': 'Dash Data Visualization'
        }
    }
)

])

app.layout = html.Div(children=[
html.H1(children='Hello Dash1'),

html.Div(children='''
    Dash1: A web application framework for Python.
'''),

dcc.Graph(
    id='example-graph1',
    figure={
        'data': [
            {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
            {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
        ],
        'layout': {
            'title': 'Dash Data Visualization'
        }
    }
)

])

But In output I am seeing only 1 DIV the latter one.How to show them as a Dashboards having multiple graphs on same url?

@chriddyp
Copy link
Member

Hi @bainadeashish - Your app can only have a single app.layout. You'll need something like:

app.layout = html.Div([
    html.Div(...),
    html.Graph(...),
    html.Div(...),
    html.Graph(...),
])

There are some examples of multiple graphs towards the end of the second chapter of the user guide: https://plot.ly/dash/getting-started-part-2

Also see the community forum to get more help on implementation questions like these: https://community.plot.ly/c/dash

byronz added a commit that referenced this issue Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants