如何将事件处理程序附加到 Google 图表?

发布于 2024-12-25 22:36:35 字数 283 浏览 2 评论 0原文

我熟悉如何通过 API 附加选择处理程序:

google.visualization.events.addListener(table, 'select', selectHandler);

但是,只有当用户选择图表上的元素(例如单击条形图)时,这才有效。如果用户单击图表中的任何空白,侦听器不会触发。我想添加一个功能,如果用户单击图表上的空白区域,则会打开一个新页面。这可以做到吗?我尝试在包含的 div 上添加 jQuery 事件处理程序,但该事件从未触发。我认为图表可以防止事件传播。

I'm familiar with how to attach a select handler via the API:

google.visualization.events.addListener(table, 'select', selectHandler);

However, this only work if a user selects an element on the chart, for example click on a bar. The listener doesn't fire if a user clicks on any whitespace in the chart. I want to add a feature where if the user clicks white space on the chart, it opens a new page. Can this be done? I've tried adding a jQuery event handler on the containing div, but the event never fires. I assume the chart prevents event propagation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文