使用 ExtJS 4 单击网格中的相关数据时突出显示图表中的条形

问题描述 投票:0回答:1

我的屏幕上有两个对象,一个网格和一个由同一商店填充的图表。 我需要做的是突出显示图表上与我在网格中单击的项目相关的列。

在函数中我想出了一半的方法来使用 Ext.getCmp('图表').series.get(0). 但不知道如何获取该系列的每个项目并突出显示它,因为 getItemForPoint(x,y) 不断返回空值...

非常感谢,代码如下:

// Code for my grid
{
 columnWidth: .25
 ,xtype: 'grid'
 ,hideHeaders: true
 ,border: true
 ,styke: 'padding-top: 60px;'
 ,height: 360
 ,store: participation
 ,columns: [{
      dataIndex: 'ID'
      ,width: 24
 },{
      dataIndex: 'Supplier'
      ,width: 204
}]
 ,listeners: {
      select: function() {
           // function to highlight the column on my chart
      }
 }
}

// Code for my chart
{
 border: false
 ,layout: 'column'
 ,items: [{
    columnWidth: .75
    ,xtype: 'chart'
    ,animate: true
    ,height: 432
    ,shadow: false
    ,id: 'chart'
    ,store: participation
    ,axes: [{
        type: 'Numeric'
        ,position: 'left'
        ,grid: true
        ,fields: 'Participation'
        ,title: 'Share'
        ,label: {
            renderer: Ext.util.Format.numberRenderer('0.00'+"%")
        }
    },{
        type: 'Category'
        ,position: 'bottom'
        ,fields: 'ID'
    }]
    ,series: [{
        type: 'column'
        ,axis: 'left'
        ,highlight: 'true'
        ,xField: 'ID'
        ,yField: 'Participation'
        ,tips: {
            trackMouse: true
            ,width: 312
            ,maxWidth: 360
            ,height: 36
            ,constrainPosition: true
            ,renderer: function(storeItem, item) {
                this.setTitle('Supplier: ' + storeItem.get('Supplier')+'<br/>'+'Share: ' + Ext.util.Format.number(storeItem.get('Share'),"0.00")+'%');
            }
        }
        ,style: {
            lineWidth: 1
            ,stroke: '#666'
        }
    }]
  }
 }
charts grid extjs4 highlight
1个回答
0
投票

查看 ExtJS 示例中的动态表单、网格和图表。该示例演示了您想要实现的目标。请参阅附加到图表和 gridPanel 的侦听器(selectionchange 事件等)。

© www.soinside.com 2019 - 2024. All rights reserved.