【问题标题】:Retrieve attributes of raphael pie chart检索拉斐尔饼图的属性
【发布时间】:2013-04-06 03:17:57
【问题描述】:

如何获取拉斐尔饼图的属性:

属性如: 笔画、数值(不带图例)、半径、x 和 y 位置

我的饼图定义为:

pie = r.piechart(120, 140, 50, [55, 22], {
    colors: ["green","red"],
    stroke: "black"   
});

我试过了:

this.stroke -- 表示未定义

// 我知道这让我得到了正确的 raphael 对象,因为我也在做一些工作

this.click(function () { 
   alert(this.stroke); 
});

this.attr('stroke'); -- 甚至不显示 undefined

知道如何解决这个问题...谢谢

【问题讨论】:

    标签: javascript jquery raphael pie-chart


    【解决方案1】:

    你可以像这样从饼图本身获取它

    console.log(this.prev.prev.prev.attrs.stroke); //I know it looks a bit ugly...
    

    或者像这样从馅饼本身

    console.log(pie.series[0].attrs.stroke);
    

    【讨论】:

    • 谢谢它的工作......还有一个问题,我们是否也可以在不使用图例和不使用标签的情况下检索值
    • 实际上我有一个饼图数组,我正在使用 $.each(array,function(i,p){ this.click(function(){ alert(this.stroke); } ); });
    • 不,它不起作用:我按照 $.each(array, function(i) { this.click(function () { alert(this.series[0].attrs.stroke); }); });
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    相关资源
    最近更新 更多