我创建了一个圆环图,但由于一些奇怪的原因我无法让听众工作。我尝试在系列内外添加监听器,但无法使其工作。
任何人都可以告诉我这里可能会遗漏的内容 下面是代码snipet
var chart = Ext.create('Rally.ui.chart.Chart',{
chartConfig: {
chart: {
type: 'pie',
/*events: {
click: function(event) {
console.dir("Clicked");
}
}*/ /*THis works but it generates events only on click of the text on the pie charts*/
},
title: {
text: 'Defects per Release Status '
},
yAxis: {
title: {
text: 'Total Defects per project'
}
},
plotOptions: {
pie: {
shadow: false,
center: ['50%', '50%']
}
},
tooltip: {
valueSuffix: '%'
},
series: [{
name: 'Teams',
data: teamData,
size: '60%',
dataLabels: {
formatter: function () {
return this.y > 5 ? this.point.name : null;
},
color: 'white',
distance: -40
}
}, {
name: 'Defects',
data: defectData,
size: '80%',
innerSize: '60%',
dataLabels: {
formatter: function () {
// display only if larger than 1
return this.y > 1 ? '<b>' + this.point.name + ':</b> ' + this.y + '%' : null;
}
}
}]
},
listeners: {
click: {
element: 'el', //bind to the underlying el property on the panel
fn: function(){ console.log('click el'); }
},
dblclick: {
element: 'body', //bind to the underlying body property on the panel
fn: function(){ console.log('dblclick body'); }
}
}
});
答案 0 :(得分:0)
将click事件添加到chartConfig.plotOptions,如下所示应该有效。您可以在this repo中看到Verdict饼图的Rally TestCaseResults的完整示例。
plotOptions : {
pie: {
allowPointSelect: true,
cursor: 'pointer',
point: {
events: {
click: function(event) {
var options = this.options;
alert(options.name + ' clicked');
}
}
},