Dear all,
this question is a follow up to:
I am trying to work with dash and css grid layout. What I would like is to structure a grid in a central place and have all my graphs and tables fill the space in the grid areas. Unfortunately the grid layout does not explicitly set width/height on the different areas. At the same time the dash graphs adapt automatically to the width of the container but the height is fixed by default. Inheriting the height is not possible because the grid elements do not have height set explicitly.
Is there another way to achieve this?
Below a minimal example of what I would like to do.
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash(__name__)
graph = 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'Montral'},
],
'layout': {
'title': 'Dash Data Visualization'
},
},
style={
# does not work in this context
'height': 'inherit',
# 'width': '90vh',
# 'height': '50vh'
}
)
app.layout = html.Div(className='wrapper',
children=[
html.Div(className='header', children=[]),
html.Div(className='leftCol', children=[]),
html.Div(className='rightCol', children=[]),
html.Div(className='midTop', children=[graph]),
html.Div(className='midBottom', children=[]),
html.Div(className='footer', children=[]),
])
CSS:
.wrapper {
display: grid;
grid-template-columns: 1fr 4fr 4fr 1fr;
grid-template-rows: 15vh 50vh 20vh 8vh;
grid-template-areas:
"header header header header"
"leftCol midTop midTop rightCol"
"leftCol midBottom midBottom rightCol"
"footer footer footer footer";
grid-gap: 5px;
}
.midTop{
grid-area: midTop;
background-color: lightgrey;
}