将 jquery 事件传递到后面的层或使内半径透明
我正在尝试在另一个饼图之上制作一个饼图(见下文),并使用 flot jquery 库。
http://cadmiumconsulting.com/carlsberg/screenshot_01.jpg
我已经设法得到了图表看起来不错,但想在外部饼图上使用鼠标事件。
我的问题是:
如果我先绘制外部图表,而内部图表位于“顶部”,则鼠标事件仅在内层上起作用。
另一方面,如果我先绘制内部图表,然后在“顶部”添加具有内半径的外部图表,则内半径在 Internet Explorer 8 中不起作用,并在内部图表的顶部显示实心圆。
关于如何将事件从一层传递到另一层或强制内半径的透明度有什么想法吗?
任何帮助表示赞赏。
更新 - “globalCompositeOperation”似乎存在问题,这将允许透明度。它包含在 html5 中,但不包含在 excanvas 对象中,这是在 IE8 中复制 canvas 对象的一种 hack。
I'm trying to make a pie chart on top of another pie chart (see below) and am using the flot jquery library.
http://cadmiumconsulting.com/carlsberg/screenshot_01.jpg
I have managed to get the diagram looking right but would like to use mouse events on the outer pie chart.
My problem is:
If I draw the outer chart first with the inner one 'on top', mouse events only work on the inner layer.
If on the other hand I draw the inner chart first and add the outer chart 'on top' with an inner radius, the inner radius doesn't work in internet explorer 8 and displays a solid circle over the top of the inner chart.
Any ideas on how to pass events from one layer to the other or force the transparency of the inner radius?
Any help appreciated.
UPDATE - There seems to be an issue with 'globalCompositeOperation' which would allow the transparency. It's included in html5 but not in the excanvas object which is a hack to replicate the canvas object in IE8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事件不断移动,因此您应该能够在后台定位图表。我做了这个
简单指南,解释事件如何传播以及如何在 jQuery 中停止它们:
首先,我们创建测试 DOM
样式:
jQuery:
我们将 click 事件绑定到 div 来测试我们的传播
Click 事件最终传播到 div
使用
event .preventDefault()
阻止所有$("a.a2")
其他绑定点击事件。使用
event.stopPropagation()
可以防止点击事件传播,并且它永远不会触发div
上的边界事件。现在我们将其结合使用。
另一种方法是返回 false;最后,这也适用于
现场
活动。希望这有帮助。
如果您需要更多帮助,请发布一些代码(在其中绑定事件)或图表示例
Events traveling so you should be able to target the chart in the background. I have made this
simple guide that explains how events travel and how to stop them in jQuery:
First we create our test DOM
Styling:
jQuery:
We bind a click event to the div to test our travelings
Click event that travels to the div eventually
Using
event.preventDefault()
prevents all$("a.a2")
other bound click events.Using
event.stopPropagation()
prevents the click event from traveling and it never triggers the bounds events on ourdiv
Now we use there to in combination.
And another way is to return false; in the end this also works for
live
events.Hopes this helps.
If you want more help please post some code (where you bind your events) or an example to your charts
“globalCompositeOperation”似乎存在允许透明度的问题。它包含在 html5 中,但不包含在 excanvas 对象中,这是在 IE8 中复制 canvas 对象的一种 hack。决定放弃我正在构建的示例并使用画布操作自己创建图表。
There seems to be an issue with 'globalCompositeOperation' which would allow the transparency. It's included in html5 but not in the excanvas object which is a hack to replicate the canvas object in IE8. Decided to abandon flot for the example I'm building and create the charts myself using canvas operations.