我正在创建一个显示数据的雷达图表,它工作得很好.但是,图例中出现的标题可能非常长.现在我把它显示在图例标题的缩短版,但是当用户执行的图例标题,工具提示鼠标悬停或泡沫的一段时间弹出,显示完整的标题/标签,我想它如此.从我在API文档中看到的,我可以看到你可以为整个图表添加一个监听器,但不仅仅是在图例标题上.
但是,您可以单击图例项以使数据显示/隐藏,因此存在某种类型的侦听功能.有关如何将自定义鼠标悬停监听器添加到以下雷达图表的图例的任何想法?
Ext.define("COM.view.portlet.RadarChart", {
extend : "Ext.panel.Panel",
alias : "widget.myradarchart",
requires: ["Ext.chart.theme.Base", "Ext.chart.series.Series"],
initComponent: function () {
//@fixme: Why is the first radar not show x-axis lines?
Ext.apply(this, {
layout: "fit",
width: 600,
height: 300,
items: {
xtype: 'chart',
style: 'background:#fff',
theme: 'Category2',
insetPadding: 20,
animate: true,
store: 'Seoradar',
legend: {
position: "bottom"
//ADDING LISTENERS HERE DOESN'T WORK
},
axes: [{
type: "Radial",
position: "radial",
maximum: 100,
label: {
font: "11px Arial",
display : "none"
}
}],
series: [{
showInLegend : true,
showMarkers : true,
markerConfig: {
radius : 2,
size : 2
},
type : 'radar',
xField : 'name',
yField : 'site0',
style: {
opacity: 0.4
}
},{
showInLegend : true,
showMarkers : true,
type : 'radar',
xField : 'name',
yField : 'site1',
style: {
opacity: 0.4
}
}]
}
});
this.callParent(arguments);
}
Run Code Online (Sandbox Code Playgroud)
});
如果您想将此事件从图表中删除,您可以将其从系列中推到图表中,方法是:
{
'type' : 'line',
'axis' : 'left',
'highlight' : true,
'listeners' : {
'itemmousedown' : function(event){
event.series.chart.fireEvent('itemmousedown', event);
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以在你的控制器中你可以说:
this.control({
'chart' : {
'itemmousedown' : function(event){
//do your stuff here
}
}
});
Run Code Online (Sandbox Code Playgroud)
!!注意力!!
我注意到这些 mousedown 事件是在 UI 上下文之外的另一个上下文中执行的,因此我无法在事件处理程序的上下文中显示窗口。我必须通过使用 setTimeout 并将事件对象保存在某处来解决这个问题。我想这可能是因为在某些浏览器上 SVG 渲染是硬件加速的。