html - Plotly Dash 不能将 div 放在同一行

标签 html row plotly dashboard plotly-dash

在 Plotly Dash 仪表板上,我无法让我的图表随着屏幕的增长而拉伸(stretch),然后在屏幕足够大时并排成一行。如果我对每个图形使用 style={"float:right"} 和 style={"float:left"} ,它将起作用,但图形将不再随屏幕一起拉伸(stretch)。我附上了一张结果图的照片。 plotly 结束/结束。我希望它们与一个大的浏览器窗口并排,然后用一个中等的浏览器窗口缩小,然后用一个小的浏览器窗口缩小/缩小。

app = dash.Dash()

app.layout = html.Div([
        dcc.Checklist(
        id='input',
        options=[
            {'label': 'Astoria', 'value': 'AST'},
            {'label': 'Warrenton', 'value': 'WAR'},
            {'label': 'Seaside', 'value': 'SEA'}
        ],
        values=['AST', 'WAR', 'SEA'],
    ),
    html.Div(className='row',
             children=[
        html.Div(
            dcc.Graph(id='value-index'),
            className='col s12 m6', 
            ),
        html.Div(
            dcc.Graph(id='rental-index'),
            className='col s12 m6',
            )
        ],

    )


])


@app.callback(
    Output('value-index', 'figure'),
    [Input(component_id='input', component_property='values')]
    )

def update_graph(input_data):

    return  {
            'data': [
                {'x': astoriaValueIndex.index, 'y': astoriaValueIndex.Value, 'type': 'line', 'name': 'Astoria'},
                {'x': warrentonValueIndex.index, 'y': warrentonValueIndex.Value, 'type': 'line', 'name': 'Warrenton'},
                {'x': seasideValueIndex.index, 'y': seasideValueIndex.Value, 'type': 'line', 'name': 'Seaside'},
            ],
            'layout': {
                'title': 'Zillow Value Index'
            }
        }


@app.callback(
    Output('rental-index', 'figure'),
    [Input(component_id='input', component_property='values')]
    )

def update_graph(input_data):

    return {
            'data': [
                {'x': astoriaRentalIndex.index, 'y': astoriaRentalIndex.Value, 'type': 'line', 'name': 'Astoria'},
                {'x': warrentonRentalIndex.index, 'y': warrentonRentalIndex.Value, 'type': 'line', 'name': 'Warrenton'},
                {'x': seasideRentalIndex.index, 'y': seasideRentalIndex.Value, 'type': 'line', 'name': 'Seaside'},
            ],
            'layout': {
                'title': 'Zillow Rental Index'
            }
        }
    [enter image description here][1]

if __name__ == '__main__':
    app.run_server(debug=True)

最佳答案

您是否尝试过使用 CSS 选项:display : Flex; ?

html.Div(className='row',
         style = {'display' : 'flex'},
             children=[
        html.Div(
            dcc.Graph(id='value-index'),
            className='col s12 m6',

            ),
        html.Div(
            dcc.Graph(id='rental-index'),
            className='col s12 m6',
            )
        ],
通常,这应该根据您想要的方式更新页面。

关于html - Plotly Dash 不能将 div 放在同一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52196991/

相关文章:

javascript - 如何在使用 JS/jQuery 单击按钮时向客户端 mapbox map 添加新图层?

html - 使 Famo.us/Angular fa-image 不可选择

r - 如何绘制已在 R 中按行排序的数据的中位数和四分位数范围?

r - 如何在稀疏点之间插入数据以在 R 和plotly 中绘制等高线图

javascript - 绘图设置颜色

JavaFX WebView 捕获来自 javascript 的 post 请求

javascript - 以编程方式删除工具栏按钮?

c - 从 C 数组中的 txt 文件第二行读取数字

php - 如何使用 PHP 和 HTML 更新 jQuery 中的行

python - 是否可以更改 Plotly 中图例框的大小?