简体   繁体   English

extJS图表自动宽度/高度

[英]extJS Chart auto width/height

I have the following extJs window which has two tabs in it. 我有以下extJs窗口,其中有两个选项卡。 One of the tab has got a column chart and the other one has a grid. 选项卡中的一个具有柱形图,而另一个具有网格。 Everything is working fine but what i want to accomplish here is that if i maximize the window the tabs size+ the charts size in the tabs should too. 一切工作正常,但我想在这里完成的是,如果我最大化窗口,则选项卡大小+选项卡中的图表大小也应如此。 How can i accomplish it. 我该怎么做。 I also have two calendar fields in the window above the tabs.. 在标签上方的窗口中,我还有两个日历字段。

var win = Ext.create('Ext.Window', {
    width: eachWindowWidth,
    height: eachWindowHeight,
    hidden: false,
    maximizable: true,
    title: 'Registered Hosts',
    renderTo: Ext.getBody(),
    items: [
        {
            xtype: 'datefield',
            name: 'time',
            fieldLabel: 'From',
            anchor: '90%'
        },
        {
            xtype: 'datefield',
            name: 'time',
            fieldLabel: 'To',
            anchor: '90%'
        },
        {
            xtype: "label",
            fieldLabel: text,
            name: 'txt',
            text: text
        },
        {
            xtype: 'tabpanel',
            activeTab: 0,
            width: eachTabWidth,
            height: eachTabHeight,
            plain: true,
            defaults: {
                autoScroll: true,
                bodyPadding: 10
            },
            items: [
                {
                    title: 'Normal Tab',
                    items: [
                        {
                            id: 'chartCmp',
                            xtype: 'chart',
                            height: 300,
                            width: 300,
                            style: 'background:#fff',
                            animate: true,
                            shadow: true,
                            store: store1,
                            axes: [
                                {
                                    type: 'Numeric',
                                    position: 'left',
                                    fields: ['data1'],
                                    label: {
                                        renderer: Ext.util.Format.numberRenderer('0,0')
                                    },
                                    grid: true,
                                    minimum: 0
                                },
                                {
                                    type: 'Category',
                                    position: 'bottom',
                                    grid: true,
                                    fields: ['name']
                                }
                            ],
                            series: [
                                {
                                    type: 'column',
                                    axis: 'left',
                                    highlight: true,
                                    tips: {
                                        trackMouse: true,
                                        width: 140,
                                        height: 28,
                                        renderer: function(storeItem, item) {
                                            this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' $');
                                        }
                                    },
                                    label: {
                                        display: 'insideEnd',
                                        'text-anchor': 'middle',
                                        field: 'data1',
                                        renderer: Ext.util.Format.numberRenderer('0'),
                                        orientation: 'vertical',
                                        color: '#333'
                                    },
                                    xField: 'name',
                                    yField: 'data1'
                                }
                            ]
                        }
                    ]
                },
                {
                    title: 'Table View',
                    xtype: 'grid',
                    width: 200,
                    height: 200,
                    collapsible: false,
                    store: store1,
                    multiSelect: true,
                    viewConfig: {
                        emptyText: 'No information to display'
                    },
                    columns: [
                        {
                            text: 'Devices',
                            flex: 50,
                            dataIndex: 'name'
                        },
                        {
                            text: 'Pass',
                            flex: 50,
                            dataIndex: 'data1'
                        }
                    ]
                }
            ]
        }
    ]
}); 

On resize event of window, change width of tabs size and the charts size however you want. 发生窗口调整大小事件时,可根据需要更改选项卡大小和图表大小的宽度。 Write a function which will execute on window resize event, In function you can access your fields like below : 编写一个将在窗口调整大小事件时执行的函数,在函数中,您可以像下面那样访问字段:

var tab = Ext.getCmp('tabId'); var tab = Ext.getCmp('tabId');

var chart = Ext.getCmp('chartId'); var chart = Ext.getCmp('chartId');

change lengths of tab and chart according to your requirement. 根据您的要求更改标签和图表的长度。 Check out window resize event here . 在此处查看窗口调整大小事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM