我目前正在编写一个flask应用程序,该应用程序旨在创建某些数据集的可视化。我正在尝试创建一个绘图,在其中可以使用CheckboxButtonGroup小部件显示/隐藏某些线条。但是,当我将图和CheckboxButton并在一起时,图不会显示在Web应用程序上,也不会引发任何错误。如果我取消选中复选框,就会出现这些图。
def gridded_plots(raw_data, TOOLS, gene_from_genome):
#Loading in and perparing data
#.
#.
#.
#
q = figure()
q0 = q.line(data['position'], data['all'], color = '#4dac26', legend = 'pcf11_DRS', alpha = 1)
q1 = q.line(data2['position'], data2['all'], color = '#b8e186', legend = 'Decay1', alpha = 1)
q2 = q.line(data3['position'], data3['all'], color = '#f1b6da', legend = 'Decay2', alpha = 1)
q3 = q.line(data4['position'], data4['all'], color = '#d01c8b', legend = 'Steinmetz', alpha = 1)
q.legend.location = "top_left"
k = figure(x_range = q.x_range)
k0 = k.line(df['position'], df['all'], color = '#4dac26', legend = 'pcf11_DRS', alpha = 1)
k1 = k.line(df2['position'], df2['all'], color = '#b8e186', legend = 'Decay1', alpha = 1)
k2 = k.line(df3['position'], df3['all'], color = '#f1b6da', legend = 'Decay2', alpha = 1)
k3 = k.line(df4['position'], df4['all'], color = '#d01c8b', legend = 'Steinmetz', alpha = 1)
k.legend.location = "top_left"
checkbox = CheckboxButtonGroup(labels=["pcf11_DRA", "Decay1", "Decay2", "Steinmetz"], active=[0, 1, 2, 3])
checkbox.callback = CustomJS.from_coffeescript(args=dict(q0=q0, q1=q1, q2=q2, q3=q3, k0=k0, k1=k1, k2=k2, k3=k3, checkbox=checkbox),
code="""
q0.visible = 0 in checkbox.active;
q1.visible = 1 in checkbox.active;
q2.visible = 2 in checkbox.active;
q3.visible = 3 in checkbox.active;
k0.visible = 0 in checkbox.active;
k1.visible = 1 in checkbox.active;
k2.visible = 2 in checkbox.active;
k3.visible = 3 in checkbox.active;
""")
col1 = column(children=[q, k], sizing_mode='stretch_both')
col2 = column(children=[s1, s2, s3, s4, s5], sizing_mode='stretch_both')
grid = gridplot([[col1, col2]])
return(grid)
def(index):
griddy = gridded_plots(raw_data, TOOLS, gene_from_genome)
global script
global div
script, div = components(griddy)
return render_template('query2.html', form = form, gene_from_genome =
gene_from_genome, upstreamBuf = upstreamBuf, downstreamBuf =
downstreamBuf, user_input_seq = user_input_seq, seq = seq, script =
script, div = div, script2 = script2, div2 = div2)