Extjs4: How to add a custom listener & tooltip to a chart?

I am creating a radar chart to display data, and it works just fine. However, the title (s) that appears in the legend can be extremely long. Right now, I have an abbreviated version of the name shown in the legend, but I would like it when the user hovers over the legend heading, a tooltip or some bubble time pops up that shows the full title / label. From what I see in the API docs, I see that you can add a listener to the entire graph, but not just the legend names.

However, you can click on the legend element to display / hide the data, so there are some listening functions. Any ideas on how to add a custom mouse listener to the legend of the next radar?

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);
}

});

+5
source share
2 answers

If you want to get this event out of the chart, you can push it from the series onto the chart by saying:

       {
            'type' : 'line',
            'axis' : 'left',
            'highlight' : true,
            'listeners' : {
                'itemmousedown' : function(event){
                    event.series.chart.fireEvent('itemmousedown', event);
                }
            }
       }

so in your controller you can say:

this.control({
    'chart' : {
         'itemmousedown' : function(event){
             //do your stuff here
         }
    }
});

!! ATTENTION!!

, mousedown , UI Context, . , setTimeout - -. , , , SVG Rendering - .

+1

series. , .

series: [
    {
        type: 'column',
        axis: 'left',
        listeners: {
            'itemmouseup': function() {
                //do something
            }
        },
        xField: 'category',
        yField: 'data1'
    }
]
0

All Articles