【问题标题】:Click event on raphael pie chart拉斐尔饼图上的点击事件
【发布时间】:2013-04-05 16:43:35
【问题描述】:

我有多个饼图,我将它们放在一个数组中:

var pie_array = new Array();

创建饼图,如:

for loop{
      pie = r.piechart(48+i*120,40,30,[100],
      {
          colors: ["white"],
          maxSlices: 1
      });
}

现在我正在为每个饼图添加点击事件:

 $.each(pie_array, function(i, p){
        $(p).click(function(){
            alert(p);
        });
    });

但是当我单击饼图时无法触发事件...有什么解决方案吗?

可能的重复: How to add jquery click event to gRaphael graphics?

how can i add click evet to my rapahel pie chart?

但没有一个解决方案有效

我什至用过:

 //below one says click event on unknown element..I printed p and it raphael set
 $.each(pie_array, function(i, p){
        p.click(function(){
            alert(p);
        });
    }); 

and

$.each(pie_array, function(i, p){
        p.node.oclick = function(){
            alert(p);
        };
    });

但没有进展

【问题讨论】:

  • 你能把你的解决方案分享给有同样问题的其他人吗?
  • @Chris:你知道要检索饼图的颜色、描边、半径等属性吗
  • 是肯定的:是肯定的 $.each(pie_array, function(i) { this.click(function () { alert("hello"); }); }); jsfiddle.net/zFCur

标签: javascript jquery raphael pie-chart


【解决方案1】:

您似乎没有将创建的饼图添加到您的数组中。

【讨论】:

  • 我将它添加到数组中,但问题不同,您无法使用问题中指定的任何解决方案附加点击事件,所有这些都是错误的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多