【发布时间】:2020-07-21 13:52:31
【问题描述】:
我是 dash 的新手,正在尝试将我使用函数创建的表格居中对齐。我已经从 SQL DB 中获取的表的数据。在破折号布局中,我尝试对表格本身使用样式,但它不起作用。样式仅适用于页面上的文本。 Df 是我没有发布的数据框,因为它与样式无关。我需要在布局中应用样式还是在函数中创建表格时应用样式?
def generate_table(dataframe, max_rows=1000):
return html.Table([
html.Thead(
html.Tr([html.Th(col) for col in dataframe.columns])
),
html.Tbody([
html.Tr([
html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
]) for i in range(min(len(dataframe), max_rows))
])
])
app.layout = html.Div(children=[
html.H2(
children='Products',
style={
'textAlign' : 'center'
}
),
generate_table(df)
])
【问题讨论】:
标签: plotly plotly-dash