在标签布局中添加多个绘图布局[散景]

问题描述 投票:1回答:1

目标:要有2个标签,每个标签有2列。在第一列中将有8个图(即8行),在第二列中将有16个表(即16行)。这些图和表通过for循环获得。

问题:如何组合绘图和表格的布局并将它们提供给选项卡。

码:

data_table_past = DataTable(source=source, columns=columns, width=900, height=100, selectable=False, editable=False, fit_columns=True)
data_table_future = DataTable(source=source, columns=columns, width=900, height=100, selectable=True, editable=False, fit_columns=True)

plots_layout = column()
tables_layout = column()

for col in col_names:
    p = figure(plot_width=700, plot_height=300, x_axis_type="datetime", toolbar_location='right')
    p.line(x=data_df["datetime"], y=data_df[col], line_width=2.5, legend=col)
    plots_layout.children.append(p)
    tables_layout.children.append(data_table_past)
    tables_layout.children.append(data_table_future)

 # Create tabs
tab1_layout = layout()
tab1_layout = tab1_layout.children.append(row(plots_layout,tables_layout)) 
tab1 = Panel(child=tab1_layout, title='Tab1')
tab2 = Panel(child=tab1_layout, title='Tab2')
tabs = Tabs(tabs=[tab1, tab2], height=500)
curdoc().add_root(tabs)

问题:似乎tab1_layout不起作用。有关如何组合“plots_layout”和“tables_layout”的任何想法,在选项卡中将有2列和多行?

谢谢!

python-3.x bokeh
1个回答
1
投票

我找到了解决方案,并分享以防其他人遇到同样的问题。

tab1_layout = layout([[plots_layout, tables_layout]])
tab2_layout = layout([[plots_layout, tables_layout]])

# Create Tabs
tab1 = Panel(child=tab1_layout, title='Tab1')
tab2 = Panel(child=tab2_layout, title='Tab2')
# Put the Panels in a Tabs object 
tabs = Tabs(tabs=[per_type, per_family], height=500)  
curdoc().add_root(tabs)
© www.soinside.com 2019 - 2024. All rights reserved.