Вопрос

I'm having trouble creating a listener for the 'itemmouseup' event for my series chart, in the controller.

Controller:

init: function () {
    this.control({
        'monthbalance > chart': {
            render: this.onChartRendered,
            itemmouseup : this.onChartClick
        },          
    });
}, 

if I insert the 'mouseup' event instead of 'itemmouseup' it works fine. But I need 'itemmouseup'. Where am I going wrong?

Thanks.

Update with view extract:

        },{
        id: 'card-1',
        xtype: 'chart',
        store: 'MonthBalances',
        title: 'This Year vs Previous Years',
        theme: 'Category1',
        legend: {position: 'right'},
        shadow: true,
        axes: [{
            type: 'Numeric',
            position: 'left',
            fields: ['monthbalance','monthlastyear','monthpreviousyear'],
            label: {
                renderer: Ext.util.Format.numberRenderer('0,0')
            },
            grid: true,
            minimum: 0
        },{
            type: 'Category',
            position: 'bottom',
            fields: ['month']
        }],

        series: [{
            type: 'line',
            title: 'this year',
            itemId: 'lineone',
            highlight: {
                size: 7,
                radius: 7
            },
            axis: 'left',
            xField: 'month',
            yField: 'monthbalance',
        //  listeners: {
        //      itemmouseup: function() {
        //          console.log('itemmouseup-thisyear');
        //      }
        //  },
        },{
            type: 'line',
            title: 'one year ago',
            itemId: 'linetwo',
            highlight: {
                size: 7,
                radius: 7
            },
            axis: 'left',
            xField: 'month',
            yField: 'monthlastyear',
        },{
            type: 'line',
            id: 'linethree',
            name: 'linethree',
            itemId: 'linethree',
            alias: 'widget.linethree',
            title: 'two years ago',
            highlight: {
                size: 7,
                radius: 7
            },
            axis: 'left',
            xField: 'month',
            yField: 'monthpreviousyear',

        }]
    }];
Это было полезно?

Решение

Because there is no itemmouseup event for Chart. This event is only available for classes that extend Ext.view.View or Ext.panel.Table

I think you need to access the series directly and not the chart that holds the series. Set your control to the series itself that you use within the chart and not to the chart. You may do this by setting the id property of the series chart so that you can bind the control to that id.

// untested but it should work
init: function () {
    this.control({
        '#your-id': {
            itemmouseup : this.onChartClick
        },          
    });
}, 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top