亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

散景:顯示/隱藏數字的小工具

散景:顯示/隱藏數字的小工具

喵喵時光機 2021-06-18 18:39:27
希望按照 UI 的方式做一些事情,如下所示:Bokeh:使用復選框小部件隱藏和顯示繪圖,其中我可以選擇性地在一列圖形中顯示/隱藏整個圖形。我可以選擇顯示哪些圖(假設我可以命名數字)的下拉菜單(帶有多個選擇的 OptionMenu)會更可取。我對JS不熟悉,有什么指導嗎?(提前致謝)我希望圖像不再可見,下一個圖形會像這樣跳起來:例如:我在生成為的列中有多個數字:from bokeh.io import output_file, showfrom bokeh.layouts import columnfrom bokeh.plotting import figureoutput_file("layout.html")x = list(range(11))y0 = xy1 = [10 - i for i in x]y2 = [abs(i - 5) for i in x]# create a new plots1 = figure(plot_width=250, plot_height=250, title=None)s1.circle(x, y0, size=10, color="navy", alpha=0.5)# create another ones2 = figure(plot_width=250, plot_height=250, title=None)s2.triangle(x, y1, size=10, color="firebrick", alpha=0.5)# create and anothers3 = figure(plot_width=250, plot_height=250, title=None)s3.square(x, y2, size=10, color="olive", alpha=0.5)# put the results in a column and showshow(column(s1, s2, s3))
查看完整描述

2 回答

?
交互式愛情

TA貢獻1712條經驗 獲得超3個贊

s1.tags, s2.tags, s3.tags = ['Foo'], ['Bar'], ['Arr'] # name your plots

plots = [s1, s2, s3]

labels = [(plots[i].tags[0]) for i in range(len(plots))]

active = list(range(0, len(plots)))


chkbx = CheckboxButtonGroup(labels=labels, active=active)


callback = CustomJS(args=dict(plots=plots, chkbx=chkbx), code="""

    for (let i = 0; i < plots.length; i++){

        plots[i].visible = chkbx.active.includes(i)

    }

    """)


chkbx.js_on_click(callback)


show(column([chkbx] + plots))

感謝@bigreddot 和他們為這個解決方案奠定基礎的答案。


查看完整回答
反對 回復 2021-06-22
  • 2 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號