# Conditional Dash layout graph item

**URL:** <https://community.plotly.com/t/conditional-dash-layout-graph-item/27511>\
**Category:** Dash Python\
**Created:** [August 20, 2019, 8:25pm UTC](https://community.plotly.com/t/conditional-dash-layout-graph-item/27511 "2019-08-20T20:25:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![austinmw](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@austinmw](https://community.plotly.com/u/austinmw)\
**Post date:** [August 20, 2019, 8:25pm UTC](https://community.plotly.com/t/conditional-dash-layout-graph-item/27511/1 "2019-08-20T20:25:51Z")

</div>

I have an app layout which originally included a `dcc.Graph` item. It bothered me that the the graph axes were displayed even before I selected anything to plot (from a dropdown item).

I then changed the graph item to a `html.Div`, with a callback where it’s output children property either gets returned an empty list or `[dcc.Graph(...)]`.

The problem I’m having now is that since this graph is now nested in the layout, I can’t seem to access its clickData. Is there an alternative way to only show a `dcc.Graph` object conditionally, but also access its clickData?

---

<div class="post-metadata">

**Author:** ![sjtrny](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sjtrny/32/12714_2.png) [@sjtrny](https://community.plotly.com/u/sjtrny)\
**Post date:** [August 21, 2019, 4:49am UTC](https://community.plotly.com/t/conditional-dash-layout-graph-item/27511/2 "2019-08-21T04:49:35Z")

</div>

You try try hiding it by setting it’s style “display” value to “none”.

```
@app.callback(Output('graph', 'style'), [Input('drop-down', 'value')])
def toggle_container(dropdown_value):
    if something
        return {'display': 'none'}
    else:
        return {'display': 'block'}
```

---

<div class="post-metadata">

**Author:** ![austinmw](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@austinmw](https://community.plotly.com/u/austinmw)\
**Post date:** [August 25, 2019, 9:08pm UTC](https://community.plotly.com/t/conditional-dash-layout-graph-item/27511/3 "2019-08-25T21:08:02Z")

</div>

Exactly what I needed, thanks!!
