You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jupyter Notebook中Plotly柱状图点击事件无法触发问题求助

Jupyter Notebook中Plotly柱状图点击事件无法触发问题求助

我遇到了一个头疼的问题——这段简单的代码没办法触发柱状图的点击事件,完全没反应。我已经试过重新安装相关包和Jupyter Notebook了,但都没用,网上相关的解决方案也很少。我现在用的是Jupyter Notebook,ipywidgets版本是8.1.5。如果有哪位朋友遇到过类似的问题,麻烦给点帮助,非常感谢!

import plotly.graph_objs as go
from IPython.display import display
import ipywidgets as widgets

fig_test = go.FigureWidget([go.Bar(x=["A", "B", "C"], y=[10, 20, 30])])

def handle_click(trace, points, state):
    print("Clicked bar indices:", points.point_inds)
    print('blah')

fig_test.data[0].on_click(handle_click)
display(fig_test)

备注:内容来源于stack exchange,提问作者Михаил

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 03:14:50