Extjs Chart Series ItemClick in Controller

时间:2014-02-26 15:55:33

标签: extjs controller series

我正在extjs中创建图表系列项目的itemclick事件

        "mychart series": {
            itemclick: function() {
                alert('s');
            }
        }

上述功能不起作用。

1 个答案:

答案 0 :(得分:0)

图表系列不是组件,因此选择器永远不会匹配。您需要中继Series事件,就像它们被图表本身触发一样,并与图表匹配:

Ext.define('My.Chart', {
    extend: 'Ext.chart.Chart',
    alias: 'widget.mychart',

    initComponent: function() {
        var me = this;

        me.callParent();

        me.series.each(function(s) {
            // This will relay Series `itemclick` event
            // as `seriesitemclick` fired on the Chart itself
            me.relayEvents(s, ['itemclick'], 'series');
        });
    }
});

Ext.define('My.Controller', {
    extend: 'Ext.app.Controller',

    init: function() {
        this.control({
            mychart: {
                seriesitemclick: this.onSeriesItemClick
            }
        });
    },

    onSeriesItemClick: function(item) {
        var sprite = item.sprite,
            series = item.series,
            record = item.storeItem,
            value  = item.value;

        ...
    }
});